Skip to content

Instantly share code, notes, and snippets.

@nilesuan
Created February 2, 2017 23:32
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 nilesuan/e9cd6404b2c53e50cc052494e0125438 to your computer and use it in GitHub Desktop.
Save nilesuan/e9cd6404b2c53e50cc052494e0125438 to your computer and use it in GitHub Desktop.
Simple in_array for javascript
var inarray = function(needle, haystack) {
var length = haystack.length;
for(var i = 0; i < length; i++) {
if(haystack[i] == needle) return true;
}
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment