Datasets and data structures in Google Apps Script

The Google Sheets editor script seems to be a variant of JavaScript, but I cannot figure out how to use it to handle sets, dictionaries, etc. I already know how to use JS arrays , but arrays are not enough for my task .

Declaring a set through the usual way (i.e. var categoryOptions = new Set(String);gives me the error "Install Undefined".

Using var categoryOptions = {};does not allow me to use any of the built-in Set functions, such as add. Instead, I get: "TypeError: cannot find the add function in the [object Object]".

Any professional advice?

+4
source share
2 answers

Google Apps Script runs on Rhino . Rhino is quite behind the times in terms of ECMAScript 5.1. Do not expect any ES6 features, such as sets or arrow functions.

There is an open issue about typing in the Rhino GitHub repository. But even if it were implemented, it’s not that Google will deploy a new version of Rhino on its servers.

+7
source

It uses ES6 for Script applications, so you can use things like Set and Map. Of course, the IDE does not support arrow functions or anything else that could violate 5.1 syntax.

http://ramblings.mcpher.com/Home/excelquirks/gassnips/es6shim

0
source

Source: https://habr.com/ru/post/1665850/


All Articles