0

I have successfully created some code to extract data from a 2D array using A1 notation. Handy to avoid multiple calls to GAS services whit ordinary getRange calls.

While the code perfectly works in javascript, it throws an error in Google Apps Script upon saving.

The offending code is:

return matrix.slice(startRow, endRow + 1).map(i => i.slice(startCol, endCol + 1))

GAS seems rejecting code in the .map function.

1 Answer 1

1

UPDATE: Google Apps Script now offers two JavaScript engines

  • Original: Based in Mozilla's Rhino JavaScript interpreter, which doesn't support several ECMAScript 5 features
  • New: Google V8, used by Chrome and Node.js, which support ECMAScript 6 but with some limitations (i.e. it doesn't support modules)

References


Your code is using an arrow function. This feature is part of ECMAScript 6 but it's not supported by default by Google Apps Script (it supports some ECMAScript 5 features but not all). Replace the arrow function by an anonymous function, add the arrow function polyfill use CLASP a desktop IDE and Babel or something similar.

References

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.