- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2024 03:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2024 03:40 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2024 03:40 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2024 03:42 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2024 03:46 AM
@AnkitT ,
You can also refer this image below
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