Behavior of for...each...in Statement

The for...each...in statement was removed as part of ECMA-357 (4x) and should no longer be used. In SuiteScript2.0, the for...each...in statement is accepted. In SuiteScript 2.1, a SyntaxError is thrown if you try to use the for...each...in statement in your script.

Scenario

SuiteScript 2.0 Behavior

SuiteScript 2.1 Behavior

Use a for...each...in statement to process values in an object:

                    var obj = {fileType: "csv", encoding: "UTF-8", isOnline: "false"};
for each(var value in obj) {
    log.debug("value = " , value);
} 

                  

The for...each...in statement is accepted and the script continues to run.

The following error is generated:

SyntaxError: SyntaxError: <eval>:3:4 Expected ( but found each for each ( var value in obj) {

Related Topics

General Notices