CodeNewbie Community 🌱

Shane
Shane

Posted on

What's the difference between double equals (==) and triple equals (===) in JavaScript?

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?

Top comments (3)

Collapse
 
murkrage profile image
Mike Ekkel

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.

Check out this MDN page for more information: developer.mozilla.org/en-US/docs/W...

Collapse
 
thegnshane profile image
Shane

You da man! Thanks!

Collapse
 
aaron profile image
Aaron McCollum

Mike hit the nail on the head!