All SuiteScript 2.0 APIs are organized into modules. Each SuiteScript 2.0 module encapsulates a specific set of functionalities. For example, you load the file module when you need to work with files in NetSuite.
In SuiteScript 2.0, the define() function returns an object that encapsulates the module you are defining. Use the define() function to load SuiteScript 2.0 modules and create custom modules. When you use the define() function, it loads all dependencies before it executes any logic.
The require() function does not return a value. The require() function is used to load modules. When you use the require() function, dependencies are not loaded until they are needed. In the example below, the record module is loaded when record.create() is called.
Some of the highlights:
# All SuiteScript 2.0 booleans take a value of true or false. All other boolean values (for example: T or F) throw an error.
# Parameter types in SuiteScript 2.0 are strictly adhered to. You must pass in valid parameter types, as listed in the SuiteScript 2.0 help. SuiteScript 2.0 does not convert invalid parameter values to valid values.
# Enumerations encapsulate common constants (for example, standard record types).
# Sublist and column indexing begins at 0.
In SuiteScript 2.0, all client scripts support the use of Promises. With Promises, developers can write asynchronous code that is intuitive and efficient. SuiteScript 2.0 provides promise APIs for selected modules only. In addition, you can create custom Promises in all client scripts.