Expedia Interview Question
Software Engineer / DevelopersCountry: United States
== is just lame. You don't ever use it since it can cause security loopholes.
[] == false
[] == 0
[] == '' // all these are true, since == boils down to same'ish-ness.
but
[] == [] //false
[] == ![] //true
So it is somewhat unstable.
=== is strict comparison. It does referential comparison for boxed values and structural comparison for unboxed values.
boxed === unboxed //always false
In javascript === and !== are strict comparison operators.
- mail4sen May 26, 2012JavaScript has both strict and type-converting equality comparison. For strict equality the objects being compared must have the same type and:
Two strings are strictly equal when they have the same sequence of characters, same length, and same characters in corresponding positions.
Two numbers are strictly equal when they are numerically equal (have the same number value). NaN is not equal to anything, including NaN. Positive and negative zeros are equal to one another.
Two Boolean operands are strictly equal if both are true or both are false.
Two objects are strictly equal if they refer to the same Object.
Null and Undefined types are == (but not ===).