Strict Mode

ECMAScript 5 introduced strict mode. If in a SuiteScript 2.0 script you assign a value to a variable without first declaring the variable using the var or const keyword, the script executes without error. If in a SuiteScript 2.1 script you assign a value to a variable without using the var, let, or const keyword, an error is thrown. For more information about strict mode, see Strict Mode.

Scenario

SuiteScript 2.0 Behavior

SuiteScript 2.1 Behavior

Place a portion of your script (or your entire script) into strict mode and assign a value to an undeclared variable:

                    'use strict';
x = 122;
log.debug('x = ', x); 

                  

Script execution completes without throwing an error.

The following error is generated:

ReferenceError: x is not defined

Related Topics

General Notices