Given this Google Apps Script script:
\'use strict\'
const foo = 2;
function bar() {
Logger.log(foo + 2);
}
Running the function bar>
From Apps Script const scoping problems
Avoid using const in Apps Script for now. It just doesn't work as it should. For now it's just a half baked version of var.
From the same source
Apps Script is based on ES3 JavaScript, with quite a few additions from ES5 and even ES6.
To read the primary source go to https://developers.google.com/apps-script/guides/services/#basic_javascript_features