Skip to content

Instantly share code, notes, and snippets.

@dented
Created August 31, 2015 03:41
Show Gist options
  • Save dented/b9a299308d8fa49f52e1 to your computer and use it in GitHub Desktop.
Save dented/b9a299308d8fa49f52e1 to your computer and use it in GitHub Desktop.
Find Value in Array
var indexOf = function(needle) {
if(typeof Array.prototype.indexOf === 'function') {
indexOf = Array.prototype.indexOf;
} else {
indexOf = function(needle) {
var i = -1,
index = -1;
for(i = 0; i < this.length; i++) {
if(this[i] === needle) {
index = i;
break;
}
}
return index;
};
}
return indexOf.call(this, needle);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment