Google Apps Script Redeclaration of Const Error

前端 未结 2 2243
失恋的感觉
失恋的感觉 2021-02-20 08:47

Given this Google Apps Script script:

\'use strict\'
const foo = 2;
function bar() {
  Logger.log(foo + 2);
}

Running the function bar

2条回答
  •  面向向阳花
    2021-02-20 09:25

    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

提交回复
热议问题