ES6 and ServiceNow (const, let and var)

Jamison Cote2
Mega Expert

Why does 'const' get processed but 'let' does not?

Both are supported in ES6 and not in ES5. The following are run in a background script.

For example:

const object1 = {
a: 'somestring',
b: 42,
c: false
};

Prints: 

*** Script: a,b,c

Yet, 

let object1 = {
a: 'somestring',
b: 42,
c: false
};

Prints: 

Javascript compiler exception: let is an ECMAScript 6 feature - not supported (null.null.script; line 1) in:
let object1 = {
  a: 'somestring',
  b: 42,
  c: false
};

The assumption here is that 'const' would not get processed by the JS engine as it's a part of ES6 functionality which is not supported by ServiceNow.
Thoughts?

5 REPLIES 5

Jace Benson
Mega Sage

Yea, I wouldnt hold your breath. I still feel like we just only got ES5 not too long ago (been 2-3 years now), but at that time it was still 5-6 years out of date.

and here we are still without ES6

This is a tall order.  I agree it should happen but we're at the mercy of when ServiceNow does this.

Yea absolutely a tall order, but while we are making requests can we get a modern bootstrap?