Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

V8 Runtime for Google Apps Scripts [duplicate]

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

like image 440
puentesdiaz Avatar asked May 26 '26 15:05

puentesdiaz


2 Answers

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.

like image 106
Aerials Avatar answered May 28 '26 03:05

Aerials


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

  • ECMAScript® 2019 Language Specification (ECMA-262, 10th edition, June 2019)

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));
}
like image 42
puentesdiaz Avatar answered May 28 '26 04:05

puentesdiaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!