The pluck function from the underscore library is used to extract an array of values for a specified property from a collection of objects.
Here's an example of how to use pluck:
index.tsx219 chars12 linesIn this example, we have an array of user objects with id and name properties. We pass this array to the pluck function along with the string 'name' indicating that we want to extract the name property of each object. The resulting array names contains the values ['John', 'Mary', 'Bob'].
Note that the pluck function returns a new array and does not modify the original collection.
gistlibby LogSnag