Difference between == and === in JS

jslearner picture jslearner · Mar 16, 2011 · Viewed 21.6k times · Source

Possible Duplicates:
Difference between == and === in JavaScript
Javascript === vs == : Does it matter which “equal” operator I use?

What's the difference between == and ===? Also between !== and !==?

Answer

jAndy picture jAndy · Mar 16, 2011

There are lots of answers to this question on Stackoverflow already.

Short:

== only compares values

=== compares values + type


var check1 = '10',
    check2 = 10;

check1 == check2 // true
check1 === check2 // false