3

Last week Google release a new Runtime. Who know which version of V8 or ECMAScript, use ?

puentesdiaz
  • 141
  • 9
  • 4
    Probably some reasonably recent version, very likely in the 7.x range at this point. Any more specific answer someone could give here might get outdated very quickly and suddenly (but you're not supposed to even notice). Why does it matter? Refer to the Apps Script documentation for supported JavaScript features. – jmrk Feb 11 '20 at 14:42
  • @jmrk Could you convert that comment to a answer or answer this question https://stackoverflow.com/questions/71089066/which-version-of-ecmascript-does-the-google-apps-script-v8-runtime-support ? I would like to close all questions related to versions as a duplicate of a canonical one. – TheMaster Feb 12 '22 at 10:26

2 Answers2

3

As per migrating scripts to v8 docs V8 standards_compliant.

However when migrating your scripts to V8 there can be some incompatibilities that you need to address or your scripts can break. While Mozilla's Rhino JS Interpreter provided a convenient way for Apps Script to execute developer scripts, it also tied Apps Script to a specific JavaScript version (ES5)

V8 implements ECMAScript 2020.

Here you have some V8 syntax examples

Hope it helps.

Aerials
  • 4,231
  • 1
  • 16
  • 20
1

Well, i can say that we have the lastest edition of ECMA262:

Here, some example from the 10th edition, introduces a few new built-in functions: flat and flatMap:

function TEST_Flats() {    
    const arr = ['a', 'b', ['c', 'd']];
    const flattened = arr.flat();
    console.log(flattened);  
}

From another editions we have:

function TEST_REST_SPREAD() {
  // ECMAScript® 2018 Language Specification (ECMA-262, 9th edition, June 2018)
  const arr1 = [10, 20, 30];
  const arr2 = [40, 50];

  // make a copy of arr1
  const copy = [...arr1];  
  console.log(copy);    

  // merge arr2 with arr1
  const merge = [...arr1, ...arr2];
  console.log(merge);       
}

And

function TEST_PAD() {
  // ECMAScript® 2017 Language Specification (ECMA-262, 8th edition, June 2017)
  let data = { "King" : "Jon Snow",
             "Queen" : "Daenerys Targaryen",
             "Hand" : "Tyrion Lannister"}

  console.log(Object.entries(data));  
  console.log(Object.values(data));  

  console.log('a'.padStart(5, 'xy'))  
  console.log('a'.padStart(4, 'xy')) 
  console.log('1234'.padStart(2, '#')) 
  console.log('###'.padStart(10, '0123456789')) 
  console.log('a'.padStart(10)) 

  console.log('a'.padEnd(5, 'xy'))  
  console.log('a'.padEnd(4, 'xy')) 
  console.log('1234'.padEnd(2, '#')) 
  console.log('###'.padEnd(10, '0123456789')) 
  console.log('a'.padEnd(10))

}

function TEST_PropertyDescriptors() {
  // ECMAScript® 2017 Language Specification (ECMA-262, 8th edition, June 2017)
  const obj = {
    id: 123,
    get bar() { return 'abc' },
  };
  console.log(Object.getOwnPropertyDescriptors(obj));
}
puentesdiaz
  • 141
  • 9