I came across very nice short explanation of the differences between == and === comparison operators. I have copied this into my blog just in case the post gets deleted from stackoverflow for whatever reason. The identity (===) operator behaves identically to the equality (==) operator except no type conversion is done, and the types must be the same to be considered equal. Reference: Javascript Tutorial: Comparison Operators The == operator will compare for equality after doing any necessary type conversions . The === operator will not do the conversion, so if two values are not the same type === will simply return false. It's this case where === will be faster, and may return a different result than ==. In all other cases performance will be the same. To quote Douglas Crockford's excellent JavaScript: The Good Parts , JavaScript has two sets of equality operators: === and !== , and their evil twins == and != . The good ones work the way you would expect. ...
Comments