Skip to content

Instantly share code, notes, and snippets.

@iwein
Forked from anonymous/str-cmp.js
Created December 15, 2012 10:15
Show Gist options
  • Save iwein/4292496 to your computer and use it in GitHub Desktop.
Save iwein/4292496 to your computer and use it in GitHub Desktop.
//make sure you understand what's happening here, you'll thank me some day
'foo' === 'bar'
false
'foo' === 'foo'
true
//watch out!
!'foo' === 'foo'
false
!'foo' === 'bar'
false
!('foo' === 'foo')
false
!('foo' === 'bar')
true
// avoid '==', let me show you why
'foo' == 'bar'
false
//watch out!
!'foo' == 'bar'
false
!'foo' == ''
true //coersion is a bitch, see?
!'foo' === ''
false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment