Created
February 7, 2014 16:00
-
-
Save bevacqua/8865658 to your computer and use it in GitHub Desktop.
Declarative variable names make for such readable code!
This file contains hidden or 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 pluck (a, prop) { | |
return a.map(function (a) { return a[prop]; }); | |
} |
This file contains hidden or 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 (a, matches) { | |
var of = Object.keys(matches); | |
return a.filter(function (a) { | |
return of.every(function (prop) { return a[prop] === matches[prop]; }); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Basic Usage
Composition