Created
October 6, 2015 17:34
-
-
Save ArielLeslie/6076f279baa35a672ba7 to your computer and use it in GitHub Desktop.
Where Art Thou
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
function where(collection, source) { | |
var arr = []; | |
// What's in a name? | |
src_keys = Object.keys(source); | |
arr = collection.filter(function(i){ | |
for(j = 0; j < src_keys.length; j++){ | |
if(!i.hasOwnProperty(src_keys[j]) || i[src_keys[j]] !== source[src_keys[j]]){ | |
return false; | |
} | |
} | |
return true; | |
}); | |
// A rose by any other name | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment