Truthy vs. Falsy Values. Double Equals vs. Triple Equals. Know the difference in three minutes. Why are we here? One simple reason. JavaScript, has two visually similar, yet , ways of testing equality. This is your high level overview of the differences. very different Triple equals (===) The triple equal sign is the one you’re probably familiar with. It tests for between two values. Both the and the you’re comparing have to be exactly the same. strict equality type value Examples of strict equality: 3 === 3 // true (Both numbers, equal values) 'test' === 'test' // true (Both Strings, equal values) false === false // true (Both Booleans, equal values) Not strict equality: 3 === '3' // false (Number compared to String) 'hello' === 'goodbye' // false (Different Strings) false === 0 // false (Different type: Boolean vs Number) Double equals (==) The double equals tests for and preforms . This means we compare two values after converting them to a common type. loose equality type coercion Lets look at an examples to help this sink in. Remember above when we tested the strict equality of a string and number? 3 === '3' // false (Number compared to String) 3 == '3' // true When we compare the number 3 with the string '3' using loose equality, we get true — they are equal. With double equals, JavaScript attempts to convert the values into a common type. In this example, JavaScript converts the string value of '3' into a number, then compares 3 and 3. Hence the true value. Falsy Values How about another example: false === 0 // false (Different type: Boolean vs Number) false == 0 // true In this example, we see that when comparing with loose equality, false == 0 evaluates to true. This is more complex example, but has to do with the fact that in JavaScript, 0 is a value. falsy In JavaScript there are only six falsy values. false (zero) 0 “” (empty string) null undefined (Not A Number) NaN Everything else in JavaScript is truthy. Comparing false, 0, and "" with loose equality (==) will result in equality: false == 0 // true 0 == "" // true "" == false // true null and undefined are only equal to themselves: null == null undefined == undefined // true null == undefined // false NaN isn’t equivalent to anything: NaN == null NaN == undefined NaN == NaN // false Key Takeaways Triple Equals === is the victor. Whenever possible, you should use triple equals to test equality. By testing the type and the value, you are always executing a true equality test. Type coercion can have some crazy rules involved (as I’ve shown above). Unless you’re very familiar with JavaScript, double equals can lead to more trouble and headaches than it’s worth. Knowing the six falsy values can go a long way to determining why something is evaluating to true or false. You did it. Good work! You can now differentiate between == & === and hopefully can remember the six falsy values is JavaScript. I publish a few articles and tutorials each week, please if you’d like to be added to my once-weekly email list. enter your email here ❤ If this post was helpful, please hit the little green heart! And don’t forget to check out my other recent articles: Build a Minimalist HTML Card in just 53 lines of code (with Flexbox) What the heck is an Immediately-Invoked Function Expression? And when you’re ready to really dive into Web Development, Check out the 5 Best Courses for Learning Full Stack Web Development