Google Apps Script Javascript Standard Support

2020-02-01 04:53发布

Simple question: Can anyone point to a resource or knows anything about which standard of Javascript is supported in Google Apps Script?

I assume naturally that ES5 is fully supported, but what about ES6 (and even 7)?

Note: I mean the built-in code editor, which will appear if you open a Spreadsheet (for example), and click Tools > Script editor...

4条回答
We Are One
2楼-- · 2020-02-01 05:21

According to the docs Apps Script is based on JavaScript 1.6.

This table explains the correlation to the ES standards.

查看更多
放荡不羁爱自由
3楼-- · 2020-02-01 05:21

In the native editor it appears you are limited to an earlier version of JS (~ES5).

There is an official tool called "Clasp" though, which lets you write typescript (.ts) files with ES6+ syntax and then compile & upload your files to Drive with clasp push --watch.

Alternatively, you can use Webpack in your local setup as detailed in this answer.

查看更多
家丑人穷心不美
4楼-- · 2020-02-01 05:24

From https://developers.google.com/apps-script/guides/services/#basic_javascript_features (January 27, 2019)

Basic JavaScript features

Apps Script is based on JavaScript 1.6, plus a few features from 1.7 and 1.8. Many basic JavaScript features are thus available in addition to the built-in and advanced Google services: you can use common objects like Array, Date, RegExp, and so forth, as well as the Math and Object global objects. However, because Apps Script code runs on Google's servers (not client-side, except for HTML-service pages), browser-based features like DOM manipulation or the Window API are not available.

查看更多
Evening l夕情丶
5楼-- · 2020-02-01 05:38

My guess is AngluarJS is since it was made by a google developer.

查看更多
登录 后发表回答