AppsScriptPulse

Google Apps Script V8 variable scopes – var, const and let – Desktop liberation

One of the key things that V8 has sorted out is the scope of variables. Using var to declare variables meant that anything declared within the scope of a function could easily be accidentally overwritten, causing hard to track down errors. ES6 (since it’s commonly known as V8 in Apps Script – I’ll be referring to it as V8 from now on), has added const and let to the variable declaration vocabulary to help prevent these kind of problems.

With the introduction to the new Google Apps Script V8 runtime new opportunities are available for writing clean and robust code in the script editor using modern JavaScript syntax. In this post from Bruce Mcpherson you can learn some of the basics of var, const and let.

Source: JavaScript V8 variable scopes – Desktop liberation

2 comments for “Google Apps Script V8 variable scopes – var, const and let – Desktop liberation

Leave a Reply

Your email address will not be published. Required fields are marked *