Can anybody explain to me why it is that something like

function baz(bar) {
    var foo = {};
    if (!bar in foo) { return false; }
    // do stuff
}

is legit whereas

function baz(bar) {
    var foo = {};
    bar in foo || return false;
    // do stuff
}

gives a syntax error?

Just in terms of the logic it seems like they should both do the same
thing, i.e. if bar is not in foo, then return false. I suppose the
difference between the two is that the first form _executes_ some code
if the conditional is false, whereas the second form _evaluates_
something if the expression on the left is falsey? I'm not really all
that surprised that it doesn't work, but I can't seem to find anything
online or even in the spec that explains exactly why that is; I'm sure
it's in there, I just can't find it.

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to