I'm doing a bit of a deep dive into the for loop and encountered ExpressionNoIn
in the spec at http://www.ecma-international.org/ecma-262/5.1/#sec-12.6.3
What does it mean?
It is explained in section 11.14 "Comma Operator ( , )":
The *NoIn
has the same structure, except that in excludes the use of the in
keyword, section 11.8 "Relational Operators":
The spec says:
The "NoIn" variants are needed to avoid confusing the
in
operator in a relational expression with thein
operator in afor
statement.
As in
may be used in two ways:
for (var x in foo) { ... }
Or:
if ('x' in foo) { ... }
The "NoIn" variants are there to make it impossible to use the second version of in
above in the first expression of the for
loop. So, the following code is invalid:
for (y = 'x' in foo; y; y = false) { ... }
ExpressionNoIn
is a non terminal from which all expressions can be derived, expect the in
operation (i.e. 'prop' in obj
).
Follow A3 from the bottom (where ExpressionNoIn
is defined) to the first *NoIn
non-terminal which does not contain a (different) *NoIn
non-terminal anymore:
RelationalExpression :
ShiftExpression
RelationalExpression < ShiftExpression
RelationalExpression > ShiftExpression
RelationalExpression <= ShiftExpression
RelationalExpression >= ShiftExpression
RelationalExpression instanceof ShiftExpression
RelationalExpression in ShiftExpression
RelationalExpressionNoIn :
ShiftExpression
RelationalExpressionNoIn < ShiftExpression
RelationalExpressionNoIn > ShiftExpression
RelationalExpressionNoIn <= ShiftExpression
RelationalExpressionNoIn >= ShiftExpression
RelationalExpressionNoIn instanceof ShiftExpression
I guess that makes it easier to distinguish for
loops from for/in
loops.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With