Skip to content

Instantly share code, notes, and snippets.

@fat
Created May 4, 2011 22:28
Show Gist options
  • Save fat/956180 to your computer and use it in GitHub Desktop.
Save fat/956180 to your computer and use it in GitHub Desktop.
better contains
var ALEX = ['foo', 'bar'];
//n00bs write:
if (ALEX.indexOf('foo') > -1) {
//ALEX contains foo
}
//pros write:
if (~ALEX.indexOf('foo')) {
//ALEX contains foo
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment