Reduce _.pluck.

Former-commit-id: 91db56f95d258070a0d25e4e4b74917e52b8cefe
This commit is contained in:
John-David Dalton
2012-12-01 10:47:00 -08:00
parent 2edb11376d
commit bb95fb7d07
2 changed files with 2 additions and 6 deletions

View File

@@ -132,7 +132,7 @@
'pairs': ['forOwn'], 'pairs': ['forOwn'],
'partial': ['isFunction', 'isObject'], 'partial': ['isFunction', 'isObject'],
'pick': ['forIn'], 'pick': ['forIn'],
'pluck': ['forEach'], 'pluck': ['map'],
'random': [], 'random': [],
'range': [], 'range': [],
'reduce': ['forEach'], 'reduce': ['forEach'],

View File

@@ -2346,11 +2346,7 @@
* // => ['moe', 'larry', 'curly'] * // => ['moe', 'larry', 'curly']
*/ */
function pluck(collection, property) { function pluck(collection, property) {
var result = []; return map(collection, property + '');
forEach(collection, function(value) {
result.push(value[property]);
});
return result;
} }
/** /**