Last active
April 18, 2018 07:00
-
-
Save itmammoth/f65388f260b57b0015ee3b13e8a093b5 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
/** | |
* Usage: | |
* var models = [{ attributes: { name: 'Scott' } }, { attributes: { name: 'Tiger' } }]; | |
* deepPluck(models, 'attributes', 'name'); //=> ['Scott', 'Tiger'] | |
*/ | |
var deepPluck = function(array) { | |
var copiedArray = [].concat(array); | |
for (var i = 1; i < arguments.length; i++) { | |
copiedArray = _.pluck(copiedArray, arguments[i]); | |
} | |
return copiedArray; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment