Regarding the ternary (? :) operator in JavaScript, I would like to know how it is evaluated by a typical browser\'s JavaScript interpreter:
Alternative A:<
According to the specification it works like in Alternative A:
The production
ConditionalExpression : LogicalORExpression ? AssignmentExpression : AssignmentExpressionis evaluated as follows:
- Let
lrefbe the result of evaluatingLogicalORExpression.- If
ToBoolean(GetValue(lref))istrue, then
- Let
trueRefbe the result of evaluating the firstAssignmentExpression.- Return
GetValue(trueRef).- Else
- Let
falseRefbe the result of evaluating the secondAssignmentExpression.- Return
GetValue(falseRef).