IfStatement :
if ( Expression ) Statement else Statement
if ( Expression ) Statement
Whenever it is unclear (ambiguous) to which if an else belongs, it should always be associated with the nearest possible if that would otherwise have no else associated to it.
function evaluate(if ( Expression ) Statement(1) else Statement(2)) {
var exprRef = evaluate(Expression);
if (ToBoolean(GetValue(exprRef))) {
return evaluate(Statement(1));
}
return evaluate(Statement(2));
}
function evaluate(if ( Expression ) Statement) {
var exprRef = evaluate(Expression);
if (ToBoolean(GetValue(exprRef))) {
return evaluate(Statement(1));
}
return Completion('normal', undefined, undefined);
}