Skip to content

Instantly share code, notes, and snippets.

@nola
Created November 26, 2013 02:12
Show Gist options
  • Select an option

  • Save nola/7652479 to your computer and use it in GitHub Desktop.

Select an option

Save nola/7652479 to your computer and use it in GitHub Desktop.
Shorter IF’z If you have multiple IF variable value comparisons you can simply ass them to an array and check for presence. You could use $.inArray as an alternative.
if( myvar==1 || myvar==5 || myvar==7 || myvar==22 ) alert('yeah')
//shorthand
if([1,5,7,22].indexOf(myvar)!=-1) alert('yeah baby!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment