---
sourceDocument: Brazil API Reference
sourceDocumentLink: https://www.servicenow.com/docs/r/api-reference

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# JavaScript modes

# JavaScript modes {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) 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 defines the design and runtime environment for custom applications and scripts, controlling which JavaScript features are available.
This setting supports existing server-side scripts and new scripts developed to the ECMAScript 2021 standard via three modes: ECMAScript 2021 (ES12), ES5 Standards, and Compatibility.
The default mode for new scoped applications is ECMAScript 2021 (ES12), while new global applications default to ES5 Standards.
Additionally, ECMAScript 2021 (ES12) mode can be enabled on individual scripts within applications using other modes.
Show full answer Show less  

## JavaScript Modes

* **ECMAScript 2021 (ES12) Mode:** Default for new scoped applications and available for individual global scripts. This mode supports a subset of ECMAScript 2021 and 2022 features such as default function parameters, rest parameters, for-of loops, template literals, destructuring, let/const declarations, arrow functions, classes, maps/sets, and optional chaining. It does not preserve legacy behaviors from pre-Tokyo JavaScript engines.
* **ES5 Standards Mode:** Default for new global applications and optional for scoped applications. It supports ECMAScript 5 features including strict mode ("use strict"), object property accessors, control over property attributes, enhanced Array and Date methods, native JSON support, and compatibility with modern third-party libraries like lodash.js and moment.js. It does not preserve legacy behaviors from pre-Helsinki engines.
* **Compatibility Mode:** Used for scripts developed before ES5 Standards mode. It differs from previous engines, with JSON.stringify() and JSON.parse() now using ES5 native JSON. Legacy JSON().encode() and JSON().decode() methods are still supported but intended only for legacy use. This mode does not support third-party JavaScript libraries.

## Practical Considerations

* Switching JavaScript modes can alter the behavior of existing scripts. It is recommended to review behavior changes and test thoroughly before changing modes.
* Configure JavaScript mode at the application level to define the ECMAScript features available across all scripts within that application.
* Enable ECMAScript 2021 (ES12) mode on individual scripts within ES5 Standards or Compatibility mode applications to utilize the latest JavaScript features selectively.  
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](https://www.servicenow.com/docs/feDR40ow0ca7mNVjzj_tOg "Compare ECMAScript features between the ECMAScript 2021 (ES12) and ES5 Standards JavaScript modes in Brazil. Both modes support a subset of ECMAScript features.").

## ECMAScript 2021 (ES12) mode {#c_JS_modes__section_qdz_bxl_gtb}

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
  {#c_JS_modes__ul_llm_52w_mtb}
* Const declaration
* Let declaration
* Arrow functions
* Class declarations
* Map set
* Optional chaining operator `(?.)`
{#c_JS_modes__ul_rdz_bxl_gtb}

To learn about specific ECMAScript 2021 (ES12) features, see the [Let's Learn ECMAScript 2021](https://www.youtube.com/playlist?list=PL3rNcyAiDYK1fUOYO83KOfF-NriBRAERV) videos on the ServiceNow Dev Program YouTube channel.

## ES5 Standards mode {#c_JS_modes__section_pjd_s34_4tb}

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
{#c_JS_modes__ul_gyz_1mq_tv}

## Compatibility mode {#c_JS_modes__section_ojd_s34_4tb}

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.
{#c_JS_modes__ul_rwm_plq_tv}

The use of third-party JavaScript libraries isn't supported in Compatibility mode.
* **[Considerations for switching JavaScript modes](https://www.servicenow.com/docs/mp2ISSNxba~NOgIBg4lpkg)**   
  Switching the JavaScript mode for an application or script might change the behavior of existing scripts. Review some examples of behavior changes before switching JavaScript modes or to troubleshoot any issues that you experience after switching.
* **[Set the JavaScript mode for an application](https://www.servicenow.com/docs/dwejP6GN73Q7Y2Af6NCqEA)**   
  Configure which ECMAScript features can be used in an application by selecting the JavaScript mode.
* **[Turn on ECMAScript 2021 (ES12) mode for a script](https://www.servicenow.com/docs/1~EtE3kxuxXEUYVJgFDVEg)**   
  Use the latest JavaScript features supported with ECMAScript 2021 (ES12) mode in server-side scripts in applications that use ES5 Standards mode or Compatibility mode.

