Where is _.pluck() in lodash version 4?

JavascriptFront End TechnologyObject Oriented Programming

Pluck has been removed from lodash 4. This is because it did the same thing as a map.

As a replacement, you can use the map function in the following way −

Example

import _ from 'lodash'
const objects = [{ 'a': 1 }, { 'a': 2 }];
console.log(_.map(objects, 'a'))

This will give the output −

Output

[1, 2]
raja
Published on 02-Dec-2019 06:05:36
Advertisements