Skip to content

Instantly share code, notes, and snippets.

@rowild
Forked from fat/gist:956180
Last active February 15, 2017 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rowild/3b0705e29a04e026a7a9cba236389237 to your computer and use it in GitHub Desktop.
Save rowild/3b0705e29a04e026a7a9cba236389237 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