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

jh1006
Tera Contributor

This is ridiculous. The last year I've had to develop in the Global scope and I have to ignore our existing coding standards. Is there any talks on upgrading the base of SN to ES6 at the very least?