uvjunw
Last Updated: February 25, 2016
·
1.7K
· steveniseki

JavaScript difference between == and ===

<b>== vs ===</b>

I think everyone knows this already just for reference...

The strict equals or identity operator === behaves identically to the equality operator == if the operands are of the same type, however the equality operator == attempts to coerce the values when operands are of different types.

<b>In case you are wondering which to use, use the identity operator ===</b>

stack overflow equals comparisons

comparison of speed

<i>"JavaScript has two sets of equality operators: === and !==, and their evil twins == and !=. The good ones work the way you would expect. If the two operands are of the same type and have the same value, then === produces true and !== produces false. The evil twins do the right thing when the operands are of the same type, but if they are of different types, they attempt to coerce the values."</i>

Quoting from Douglas Crockford JavaScript the good parts