Skip to content

Instantly share code, notes, and snippets.

@adeolaawoyemi
Created November 15, 2012 00:37
Show Gist options
  • Save adeolaawoyemi/4075859 to your computer and use it in GitHub Desktop.
Save adeolaawoyemi/4075859 to your computer and use it in GitHub Desktop.
String.inArray() method
String.prototype.inArray = function(arr) {
for (var i = arr.length - 1; i >= 0; i--) {
if (arr[i] == this.toString()) return true;
};
return false;
};
"dick".inArray(["tom", "dick", "harry"]); // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment