As the ECMAScript specification continues to evolve at a rapid pace, it improves developer productivity, such as freedom from rewriting a lot of the same code over and over. The expressivity and power offered by the latest standards make it possible to write modern server-side code using arrow functions, block-scoped variables, spread operators and more.
Let’s take a closer look at just a few of these:
Spread Operator & Arrow Functions
Use the spread operator (“…”) to quickly combine two objects together into a single object as shown below. Couple that with the easy-to-use arrow functions to simplify function scope.
Quickly unpack properties from an object into distinct variables using destructuring assignment.
For a complete overview of all ECMAScript features, please refer to the 2019 Specification.
There are a few more items that you’ll find useful. Currently, server-side scripts annotated as @NApiVersion 2.x execute as SuiteScript 2.0. As a part of this release, NetSuite has added an account-level preference giving you the flexibility to execute your server-side scripts annotated with @NApiVersion 2.x as SuiteScript 2.1. If for any reason you need to change the runtime behavior back to SuiteScript 2.0, it's as easy as flipping a switch.
These updates give you ample time to test all your server-side applications and libraries on the new engine powering SuiteScript 2.1 before rolling out to production. For more information on implementation timelines please visit the documentation page, and make sure you speak with your administrator as you plan for any changes.
Aligning SuiteScript with ECMAScript delivers enhanced developer productivity, more maintainable code and ensures ongoing conformance to an evolving standard, opening up a wide range of new possibilities for NetSuite customization. Here are a few resources to learn more:
- Getting Started with SuiteScript 2.1
- Differences between SuiteScript 2.0 and SuiteScript 2.1
- Transition period for SuiteScript 2.x
- Enabling SuiteScript 2.1 at an Account Level