BeardsAndFlannels, CA 94103

T3h blog

== vs === in JavaScript
January 1st, 2015

I thought it might be useful to make a post as a quick reference between the == (abstract comparison) and === (strict comparison) operators. It's typically taught that the best practice is to default to ===. The essential difference is that == checks for equality with type coercion where === does it without coercion. As a result, using == opens up the comparison to resulting in a true value in many more scenarios.

(== i.e. abstract comparison)

(=== i.e. strict comparison)

For a more detailed account of all this, check out MDN.

Back to Blog Summaries