Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Edition of ECMA-262 Does Google Apps Script Support?

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?

like image 989
chrisbateskeegan Avatar asked Jun 22 '13 15:06

chrisbateskeegan


People also ask

Is Google Appscript JavaScript?

Google Apps Script is a rapid application development platform that makes it fast and easy to create business applications that integrate with Google Workspace. You write code in modern JavaScript and have access to built-in libraries for favorite Google Workspace applications like Gmail, Calendar, Drive, and more.

What type of script does Google use?

Want the Google apps to do more? Google Apps Script is a coding language based on JavaScript that allows you to extend and manipulate Google apps like Drive, Sheets, Docs, and Gmail.

Is App script similar to JavaScript?

Apps Script is essentially JavaScript. It's based on a slightly earlier version of JavaScript, so in effect, it's like JavaScript without some of the newer syntax. If you know Apps Script, it would require relatively little effort to make the bridge to the latest and greatest JavaScript.


2 Answers

The documentation says that the old runtime is based on Mozilla's Rhino JavaScript interpreter which provides a subset of ECMAScript 5 and is based on 1.6, with a smattering of 1.7 and 1.8.

The new Apps Script runtime is supported by the V8 runtime with few exceptions like E6 Modules.

like image 160
Mogsdad Avatar answered Sep 27 '22 20:09

Mogsdad


From Built-in Google Services

Apps Script supports two JavaScript runtimes: the modern V8 runtime and an older one powered by Mozilla's Rhino JavaScript interpreter.

The V8 runtime supports modern ECMAScript syntax and features. The Rhino runtime is based on the older JavaScript 1.6 standard, plus a few features from 1.7 and 1.8. You can freely choose which runtime to use with your script, but the V8 runtime is strongly recommended.

like image 27
Rubén Avatar answered Sep 27 '22 20:09

Rubén