Skip to content

Instantly share code, notes, and snippets.

@markmarkoh
Created April 26, 2012 18:13
Show Gist options
  • Select an option

  • Save markmarkoh/2501584 to your computer and use it in GitHub Desktop.

Select an option

Save markmarkoh/2501584 to your computer and use it in GitHub Desktop.
Rick Ford!!
/*
Equality operators: ===, !== vs. ==, !=
The second set are the 'evil twins'. They attempt to coerce values,
but do a real crap job of it.
Evidence:
*/
'' == 0 // true
0 == '0' // true
// therefore '' equals '0'? Right? Right??? Wrong:
'' == '0' // false.
'' == 0 // true
0 == ' \t\r\n ' // true
// same punchline as above:
'' == ' \t\r\n ' // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment