Frontend developer by day, iOS developer by night. Currently working on learning iOS development and my own blog, Mike Decodes, where I'm decoding the tech industry. Come hang out with me on Twitter!
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 to true.
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 to false because type number is not the same as type string.
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!