Created
August 12, 2010 16:56
-
-
Save galvez/521276 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
utils = { | |
subset_of: function(arr) { | |
for(var i = arr.length, d = {}; i--;) d[arr[i]] = 1; | |
var p, before = 0, after = 0; | |
for(p in d) before++; | |
for(i = this.length; i--;) d[this[i]] = 1; | |
for(p in d) after++; | |
return after == before; | |
} | |
} | |
arr = [1,2]; | |
arr.subset_of = utils.subset_of; | |
console.log(arr.subset_of([2,3,4])); // false | |
console.log(arr.subset_of([1,2,3,4])); // true | |
// #flashcodersfeelings |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LOL