_.pluck

array.map or .map can also be used to replace .pluck. Lodash v4.0 removed .pluck in favor of .map with iteratee shorthand. Details can be found in Changelog

  1. // Underscore/Lodash
  2. var array1 = [{name: "Alice"}, {name: "Bob"}, {name: "Jeremy"}]
  3. var names = _.pluck(array1, "name")
  4. console.log(names)
  5. // output: ["Alice", "Bob", "Jeremy"]
  6.  
  7. // Native
  8. var array1 = [{name: "Alice"}, {name: "Bob"}, {name: "Jeremy"}]
  9. var names = array1.map(function(x){
  10. return x.name
  11. })
  12. console.log(names)
  13. // output: ["Alice", "Bob", "Jeremy"]

Browser Support for Array.prototype.map()

ChromeEdgeFirefoxIEOperaSafari
1.5 ✔9.0 ✔