Skip to content

Instantly share code, notes, and snippets.

@mnutt
Created June 24, 2009 05:14
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 mnutt/135027 to your computer and use it in GitHub Desktop.
Save mnutt/135027 to your computer and use it in GitHub Desktop.
function containsArray(haystack, needle) {
var matched = 0;
for(var i in haystack) {
if(haystack[i] == needle[matched]) {
matched = matched + 1;
if(matched == needle.length) {
return i - matched + 1;
}
} else { matched = 0; }
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment