JavaScript modes

  • Release version: Australia
  • Updated March 12, 2026
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of JavaScript modes

    JavaScript mode in ServiceNow controls the design and runtime settings for custom applications and scripts, determining which JavaScript features are available. There are three modes supported by the JavaScript engine to accommodate existing server-side scripts and new ECMAScript standards:

    Show full answer Show less
    • ECMAScript 2021 (ES12)
    • ES5 Standards
    • Compatibility

    These modes help balance support for modern JavaScript features while maintaining compatibility with legacy scripts.

    Key Features

    • ECMAScript 2021 (ES12) mode:
      • Default for new scoped applications.
      • Supports modern ECMAScript 2021 and 2022 features like default function parameters, rest parameters, for-of loops, template literals, destructuring, const/let, arrow functions, classes, Map and Set, and optional chaining (?.).
      • Not supported for global applications by default but can be enabled for individual global scripts.
      • Does not preserve legacy behaviors from pre-Tokyo JavaScript engine versions.
    • ES5 Standards mode:
      • Default for new global applications and available for scoped applications.
      • Supports ECMAScript 5 syntax and features such as "use strict", object extensibility control, property accessors, control over property writability/configurability/enumerability, new Array and Date methods, and native JSON support.
      • Enables use of modern third-party libraries like lodash.js and moment.js.
      • Does not preserve legacy behaviors from pre-Helsinki JavaScript engine versions.
    • Compatibility mode:
      • Used for scripts developed before ES5 Standards mode was introduced.
      • JSON methods now use ES5 native JSON, but legacy JSON encoding/decoding methods remain supported for backward compatibility.
      • Does not support third-party JavaScript libraries.

    Important Considerations for ServiceNow Customers

    • Switching JavaScript modes can alter script behavior; it is important to review examples of behavior changes and test scripts thoroughly before and after changing modes.
    • Customers can configure the JavaScript mode at the application level to control which ECMAScript features are available.
    • Individual scripts within applications using ES5 Standards or Compatibility mode can enable ECMAScript 2021 (ES12) mode to leverage the latest JavaScript features without changing the entire application mode.

    JavaScript mode is a design and runtime setting for custom applications and scripts. To support existing server-side scripts and new scripts developed to the ECMAScript 2021 standard, the JavaScript engine has three modes: ECMAScript 2021 (ES12), ES5 Standards, and Compatibility.

    The JavaScript mode controls which JavaScript features you have access to in an application or script. The default mode for new scoped applications is ECMAScript 2021 (ES12) and for new global applications, it’s ES5 Standards. You can also turn on ECMAScript 2021 (ES12) mode for individual scripts in applications that use ES5 Standards or Compatibility mode.

    For more information about features supported by the ECMAScript 2021 (ES12) and ES5 Standards modes, see JavaScript engine feature support.

    ECMAScript 2021 (ES12) mode

    ECMAScript 2021 (ES12) mode is the default mode when you create new scoped applications. It isn't supported for global applications but can be turned on for individual global scripts.

    When you create new scripts, ECMAScript 2021 (ES12) mode is turned on by default regardless of the JavaScript mode configured for the application. This mode doesn’t preserve the legacy behaviors in the pre-Tokyo JavaScript engine.

    ECMAScript 2021 (ES12) mode supports a subset of ECMAScript 2021 (ES12) and ECMAScript 2022 (ES13) syntax and features, including the following features:
    • Default function parameters
    • Rest parameters
    • For-of loops
    • Template literals
    • Destructuring
      • Declarations
      • Assignment
      • Parameters
    • Const declaration
    • Let declaration
    • Arrow functions
    • Class declarations
    • Map set
    • Optional chaining operator (?.)

    To learn about specific ECMAScript 2021 (ES12) features, see the Let's Learn ECMAScript 2021 videos on the ServiceNow Dev Program YouTube channel.

    ES5 Standards mode

    ES5 Standards mode is the default mode for new global applications and is an option for scoped applications. This mode doesn’t preserve the legacy behaviors in the pre-Helsinki JavaScript engine.

    ES5 standards mode supports ECMAScript5 syntax and features, including the following features:
    • The "use strict" declaration
    • Control over extensibility of objects
    • Get and set properties on objects (accessors)
    • Control over writability, configurability, and enumerability of object properties
    • New Array and Date methods
    • Native JSON support
    • Support for modern third-party libraries such as lodash.js and moment.js

    Compatibility mode

    Compatibility mode is used for all scripts developed prior to the addition of ES5 Standards mode. Compatibility mode has some differences from the previous JavaScript engine.

    JSON support changes:
    • JSON.stringify() and JSON.parse() are implemented using the ES5 Native JSON object.
    • The new JSON().encode() and new JSON().decode() are still supported, but should only be used when the legacy behavior is required.

    The use of third-party JavaScript libraries isn’t supported in Compatibility mode.