2.1.39 [ECMA-262-1999] Section 12.6.3, The for Statement

V0057:

The production IterationStatement : for (ExpressionNoInopt ; Expressionopt ; Expressionopt) Statement is evaluated as follows:

Step 1 below contains a specification error that is documented in ES3 Errata. JScript 5.x implements the following algorithm as corrected in the errata document.

  1. If #the first Expression#__ExpressionNoIn__ is not present, go to step 4.

  2. Evaluate ExpressionNoIn.

  3. Call GetValue(Result(2)). (This value is not used.)

  4. Let V = empty.

  5. If the first Expression is not present, go to step 10.

  6. Evaluate the first Expression.

  7. Call GetValue(Result(6)).

  8. Call ToBoolean(Result(7)).

  9. If Result(8) is false, go to step 19.

  10. Evaluate Statement.

  11. If Result(10).value is not empty, let V = Result(10).value.

  12. If Result(10).type is break and Result(10).target is in the current label set, go to step 19.

  13. If Result(10).type is continue and Result(10).target is in the current label set, go to step 15.

  14. If Result(10) is an abrupt completion, return Result(10).

  15. If the second Expression is not present, go to step 5.

  16. Evaluate the second Expression.

  17. Call GetValue(Result(16). (This value is not used.)

  18. Go to step 5.

  19. Return (normal, V, empty).

V0058:

The production IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement is evaluated as follows:

Step 7 below contains a specification error that is documented in ES3 Errata. JScript 5.x implements the following algorithm as corrected in the errata document.

  1. Evaluate VariableDeclarationListNoIn.

  2. Let V = empty.

  3. If the first Expression is not present, go to step 8.

  4. Evaluate the first Expression.

  5. Call GetValue(Result(4)).

  6. Call ToBoolean(Result(5)).

  7. If Result(6) is false, go to step #14#__17__.

  8. Evaluate Statement.

  9. If Result(8).value is not empty, let V = Result(8).value.

  10. If Result(8).type is break and Result(8).target is in the current label set, go to step 17.

  11. If Result(8).type is continue and Result(8).target is in the current label set, go to step 13.

  12. If Result(8) is an abrupt completion, return Result(8).

  13. If the second Expression is not present, go to step 3.

  14. Evaluate the second Expression.

  15. Call GetValue(Result(14)). (This value is not used.)

  16. Go to step 3.

  17. Return (normal, V, empty).