4 ms·
I actually did a === check for just that reason, since if you define _ = {}, then passing in a real object that is {} will also return true for _ == {}
by youngnh 17y ago
I actually did a === check for just that reason, since if you define _ = {}, then passing in a real object that is {} will also return true for _ == {}
- tlrobinson 17y agoNope: js> a = {} [object Object] js> b = {} [object Object] js> a == b false == only casts between certain primitive types, it doesn't do a deep comparison: js> x = null null js> y = undefined js> x == y true js> x === y false Also undefined comparisons are still true with ===: js> var _ js> _ === undefined true But you're right, === should be the default choice, and only use == if you have a good reason.