{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":597,"path":"api-reference/scripts/c_JS_modes.md","title":null,"bundle":null,"doc_type":null,"release":null,"body":"---\ntitle: JavaScript modes\ndescription: 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.\nlocale: en-US\ncanonical_url: https://www.servicenow.com/docs/r/australia/api-reference/scripts/c\\_JS\\_modes.html\nrelease: australia\nproduct: Scripts\nclassification: scripts\ntopic_type: concept\nlast_updated: \"2026-03-12\"\nreading_time_minutes: 2\nbreadcrumb: [JavaScript engine, Server-side scripting, Scripting, API implementation, API implementation and reference]\n---\n\n# JavaScript modes\n\nJavaScript 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.\n\nThe 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.\n\nFor more information about features supported by the ECMAScript 2021 \\(ES12\\) and ES5 Standards modes, see [JavaScript engine feature support](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/javascript-engine-feature-support.md).\n\n## ECMAScript 2021 \\(ES12\\) mode\n\nECMAScript 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.\n\nWhen 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.\n\nECMAScript 2021 \\(ES12\\) mode supports a subset of ECMAScript 2021 \\(ES12\\) and ECMAScript 2022 \\(ES13\\) syntax and features, including the following features:\n\n-   Default function parameters\n-   Rest parameters\n-   For-of loops\n-   Template literals\n-   Destructuring\n    -   Declarations\n    -   Assignment\n    -   Parameters\n-   Const declaration\n-   Let declaration\n-   Arrow functions\n-   Class declarations\n-   Map set\n-   Optional chaining operator `(?.)`\n\nTo 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.\n\n## ES5 Standards mode\n\nES5 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.\n\nES5 standards mode supports ECMAScript5 syntax and features, including the following features:\n\n-   The \"use strict\" declaration\n-   Control over extensibility of objects\n-   Get and set properties on objects \\(accessors\\)\n-   Control over writability, configurability, and enumerability of object properties\n-   New Array and Date methods\n-   Native JSON support\n-   Support for modern third-party libraries such as lodash.js and moment.js\n\n## Compatibility mode\n\nCompatibility 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.\n\nJSON support changes:\n\n-   JSON.stringify\\(\\) and JSON.parse\\(\\) are implemented using the ES5 Native JSON object.\n-   The new JSON\\(\\).encode\\(\\) and new JSON\\(\\).decode\\(\\) are still supported, but should only be used when the legacy behavior is required.\n\nThe use of third-party JavaScript libraries isn’t supported in Compatibility mode.\n\n-   **[Considerations for switching JavaScript modes](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/considerations-switching-javascript-mode.md)**  \nSwitching 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.\n-   **[Set the JavaScript mode for an application](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/set-javascript-mode-application.md)**  \nConfigure which ECMAScript features can be used in an application by selecting the JavaScript mode.\n-   **[Turn on ECMAScript 2021 \\(ES12\\) mode for a script](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/set-es12-mode-scripts.md)**  \nUse the latest JavaScript features supported with ECMAScript 2021 \\(ES12\\) mode in server-side scripts in applications that use ES5 Standards mode or Compatibility mode.\n\n**Parent Topic:**[JavaScript engine on the platform](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/c_JS_engine_upgrade.md)\n\n"}}