11.8 Relational operators

2010-05-17

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

As you can see, there are two almost identical Productions, one with and one without the in operator. The main reason is to be able to distinct an iterative for loop from an each loop. The in keyword would otherwise be ambigous in the for context. (is it really? could the absence of ;; not automatically allow the in keyword expression? then we could do away with the whole NoIn crap). For the relational operators above there is no difference in how the normal and the NoIn version is evaluated.

The relational operators are actually binary operators, which take two operands. One before and one after the keyword.

These operators always return a boolean, true or false.