8

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...

Selfish
  • 6,023
  • 4
  • 44
  • 63
  • 1
    Anyone who would know the answer is more likely to see your question and answer it at the [Apps Script Group - LINK](https://plus.google.com/u/0/communities/102471985047225101769) I don't know of any official documentation for this. Issues related to this have been discussed in the Apps Script group, for example: let and const are part of es6 specification, and have not been implemented in the Apps Script js engine. (As far as I know, at this moment in time) Whether Apps Script server side code supports something is probably just trial and error. – Alan Wells Jun 11 '16 at 21:43
  • Thanks @SandyGood - I'll transfer the question. – Selfish Jun 11 '16 at 21:44
  • `const` is valid in Apps Script btw, but `let` is (currently) not – tehhowch Aug 16 '18 at 14:09

4 Answers4

13

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

This table explains the correlation to the ES standards.

Andrew Roberts
  • 2,720
  • 1
  • 14
  • 26
3

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.

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • Do you know whether there is any other more exact specification especially which `1.7` and `1.8` features are available as an alternative to just trying something out and finding it doesn't work (like arrow functions)? – t3chb0t Oct 22 '19 at 18:11
2

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.

Akshay Raje
  • 852
  • 9
  • 20
Dustin Michels
  • 2,951
  • 2
  • 19
  • 31
-11

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

Mark Keane
  • 984
  • 2
  • 11
  • 26
  • I didn't quite get that. AngularJS is not a standard of JS, and isn't used in Apps Script. I wasn't asking which framework was Google Drive implemented in, if this is what you intended. – Selfish Jun 11 '16 at 21:09