foo == bar; /* true */ foo + bar == foo + bar; /* false */ foo++-++bar == bar++-++foo; /* false */
foo
bar
var foo = { toString: function () { return NaN; } }; var bar = foo; alert([ foo == bar, foo++-++bar==bar++-++foo ]);
foo = bar = { a: 0, valueOf:function(){return this.a++;} }; alert(foo==bar); /* true */ alert(foo++-++bar==bar++-++foo); /* false */
var foo = undefined, bar = undefined; alert([ foo == bar, foo + bar == foo + bar, foo++-++bar == bar++-++foo ]);