Skip to content

Instantly share code, notes, and snippets.

@leandro
Forked from galvez/subset_of.js
Created August 12, 2010 18:58
Show Gist options
  • Save leandro/521491 to your computer and use it in GitHub Desktop.
Save leandro/521491 to your computer and use it in GitHub Desktop.
var
a = [1,2,3,4,5],
b = [2,3],
subset_of = function(arr, arr_sub) { return new RegExp("-" + arr_sub.join('-') + "-").test("-" + arr.join('-') + "-"); };
console.log(subset_of(a, b)); // true
console.log(subset_of(a, b.reverse())); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment