Skip to content

Instantly share code, notes, and snippets.

@MoritzBuetzer
Created July 10, 2014 11:46
Show Gist options
  • Save MoritzBuetzer/0446ac74684a674bfb83 to your computer and use it in GitHub Desktop.
Save MoritzBuetzer/0446ac74684a674bfb83 to your computer and use it in GitHub Desktop.
Check if value is in Array
Array.prototype.inArray = function (value) {
var i;
for (i=0; i < this.length; i++) {
if (this[i] === value) {
return true;
}
}
return false;
};
//[1,2,3].inArray(2) > true
//[1,2,3].inArray(22) > false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment