The pluck function is used on an array of objects to pick the value of the given property from every object inside it.
In this example, we are plucking name from every object inside users array:
pluck can also be used on nested objects having a similar structure. Consider the following example:
It can also be used with nested arrays if we provide the index.
Here we provided the index 0 for the names array. This means it takes the value at index 0 for each sub-list of names.
Similarly, to get the values at index 1 for each sub-list of names we would do as follows: