Which ECMA Script version supported by ServiceNow and is it possible to use globally?

AnkitT
Tera Contributor
 
1 ACCEPTED SOLUTION

Abhishek_Thakur
Mega Sage

Hello @AnkitT ,

 

ECMA Script 5 which introduced in 2021 called ES2021 is used, and we can only use it for scoped applications, but if you use it globally it will give you the syntax error even though it will work.

View solution in original post

3 REPLIES 3

Abhishek_Thakur
Mega Sage

Hello @AnkitT ,

 

ECMA Script 5 which introduced in 2021 called ES2021 is used, and we can only use it for scoped applications, but if you use it globally it will give you the syntax error even though it will work.

Community Alums
Not applicable

Hi @AnkitT ,

ServiceNow Supports JavaScript ECMA 6 which is also called Vanilla JavaScript. The arrow notation you're talking about (=>) is actually supported by JavaScript ECMA Script 2021 in ServiceNow which is introduced in Tokyo release. This is only supported in Scoped Application & not in Global.

ServiceNow still understands Vanilla Script but there is a translator in between which translate all the new JavaScript into the older one and then it executes. 

If you need more information please visit this blog post.

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak

Community Alums
Not applicable

@AnkitT ,

You can also refer this image below 

SarthakKashyap_0-1715856353401.png

var array1 = [1, 4, 9, 16];

// Pass a function to map
var map1 = array1.map((x) => x * 2);

gs.print(map1);
// Expected output: Array [2, 8, 18, 32]

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak