问题
According to this thread from the old Google Group, Apps Script is based on ECMA-262 3rd Edition.
This would seem to be supported by the fact that auto-completion in the editor displays 3rd Edition array functions.
However the following code runs perfectly well, which casts doubt on the matter:
var array = [
1,2,3,4,5
];
Logger.log(\"forEach:\");
array.forEach(function (item,idx,arr) {
Logger.log(item);
});
Note the use of ECMA-262 5th Edition Array function forEach.
Would someone authoritative mind giving a definitive answer on why this is the case? And whether it\'s safe to rely on all 5th Edition features or a sub-set that have been implemented and seem to work?
回答1:
The current documentation (June 2013) says Apps Script provides a subset of ECMAScript 5 and is based on JavaScript 1.8.
Edit: Google has backtracked somewhat. As of Nov 2013, they are reporting that Apps Script is based on 1.6, with a smattering of 1.7 and 1.8.
来源:https://stackoverflow.com/questions/17252409/which-edition-of-ecma-262-does-google-apps-script-support