When should you use === vs ==, !== vs !=, etc.. in javascript?

Matt picture Matt · Jul 7, 2009 · Viewed 10.9k times · Source

Possible Duplicate:
Javascript === vs == : Does it matter which “equal” operator I use?

What are the differences between === vs == and !== vs !=?

When should you use each one?

Answer

Matthew Vines picture Matthew Vines · Jul 7, 2009

=== is the Identity operator, and is used to test that value and type are equal.

so..

"3" == 3 // true
"3" === 3 // false
1 == true // true
1 === true // false
"1" == true // true
"1" === true // false

so when you care that value and type are equal, or not equal use Identity operators === or !==