1 var map = require('./map'),
2 property = require('../utility/property');
5 * Gets the property value of `path` from all elements in `collection`.
10 * @param {Array|Object|string} collection The collection to iterate over.
11 * @param {Array|string} path The path of the property to pluck.
12 * @returns {Array} Returns the property values.
16 * { 'user': 'barney', 'age': 36 },
17 * { 'user': 'fred', 'age': 40 }
20 * _.pluck(users, 'user');
21 * // => ['barney', 'fred']
23 * var userIndex = _.indexBy(users, 'user');
24 * _.pluck(userIndex, 'age');
25 * // => [36, 40] (iteration order is not guaranteed)
27 function pluck(collection, path) {
28 return map(collection, property(path));
31 module.exports = pluck;