Skip to content

Instantly share code, notes, and snippets.

@tekaratzas
Last active July 24, 2017 20:59
Show Gist options
  • Save tekaratzas/953a556f720edf39173aff2701921ea1 to your computer and use it in GitHub Desktop.
Save tekaratzas/953a556f720edf39173aff2701921ea1 to your computer and use it in GitHub Desktop.
Difference between "==" and "===" in JS.
// examples with ==
1 == "1" // true
"/t" == 0 // true
"34" == 2 // false
new Number(10) == 10 // true
Number(10) === 10 //true
// examples with ===
1 === "1" // false
"/t" === 0 // false
"34" === 2 // false
10 === 10 //true
// where things get wierd....
Number(10) === 10 //true
new Number(10) === 10 //false, LHS will actually be an object!
@DannyFeliz
Copy link

In line 4 there is an error.

"/t" == 0 // false

Maybe you mean this

"\t" == 0 // true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment