19

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 !==?

Community
  • 1
  • 1
jslearner
  • 21,331
  • 18
  • 37
  • 35

2 Answers2

36

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
jAndy
  • 231,737
  • 57
  • 305
  • 359
1

"==" means equals, whereas "===" means identically equal.

In short, "==" will try and coerce/convert the types of values when doing a comparison, so "2"==2, whereas "===" will not.

Rob Levine
  • 40,328
  • 13
  • 85
  • 111