Hey guys, Shane here. I'm trying to wrap my head around the issue of double equals (==) vs. triple equals (===) in JavaScript - can anyone help me figure out how they're different?
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (3)
Hey Shane! So in their core they do the same: check equality (does left equal right). However, the way they do so differs.
The double equals (==) is an abstract equality check. What this means is that either valueβs type can be converted to another type during comparison. So
0 == β0β
evaluates totrue
.The triple equals (===) is a strict equality check. What this means is that it requires both values to be of the same type. So
0 == β0β
evaluates tofalse
because typenumber
is not the same as typestring
.Check out this MDN page for more information: developer.mozilla.org/en-US/docs/W...
You da man! Thanks!
Mike hit the nail on the head!