Use & Abuse: Underscore's pluck
From the official docs (http://underscorejs.org/#pluck):
_.pluck(list, propertyName)
"A convenient version of what is perhaps the most common use-case for map: extracting a list of property values."
pluck is very useful for things like:
var fruits = [
{ name: 'apple', color: 'red' },
{ name: 'banana', color: 'yellow' },
{ name: 'orange', color: 'orange' }
];
_.pluck(fruits, 'name'); // returns ['apple', 'banana', 'orange']
Written by Héliton Nordt
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Underscore.js
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#