Retrieve only one field from object/array using underscore.js
arrays, javascript, lodash, node.js, underscore.js
Solution
_.pluck([{name: 'x'}, {name: 'y'}],"name");
this will give you: ["x","y"];
see http://underscorejs.org/#pluck
Problem
In ruby I'm able to do the following: ``` myObject.map(&:name) ``` And I get an array composed by all the `name` field for all values inside `myObject` (array or object). What's the underscore.js or lodash.js equivalent? I prefer in only one line if possible :) Example: (in js) ``` _.map([{name: 'x'}, {name: 'y'}], function(obj){ //dosomething }) ```