Syntax error What is the replacement of lodash pluck() method?

What is the replacement of lodash pluck() method?



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'))

Output

This will give the output −

[1, 2]
Updated on: 2019-12-02T06:06:54+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements