es5-compliance
Installation
SKILL.md
ES5 Compliance for ServiceNow
ServiceNow runs on Mozilla Rhino engine which only supports ES5 JavaScript (2009 standard). All server-side scripts MUST use ES5 syntax.
Forbidden Syntax (WILL CAUSE SyntaxError)
| ES6+ Syntax | ES5 Alternative |
|---|---|
const x = 5 |
var x = 5 |
let items = [] |
var items = [] |
() => {} |
function() {} |
`Hello ${name}` |
'Hello ' + name |
for (x of arr) |
for (var i = 0; i < arr.length; i++) |
{a, b} = obj |
var a = obj.a; var b = obj.b; |
[a, b] = arr |
var a = arr[0]; var b = arr[1]; |
...spread |
Use Array.prototype.slice.call() |
class MyClass {} |
Use constructor functions |
async/await |
Use GlideRecord callbacks |
Promise |
Use GlideRecord with callbacks |