Skip to content
Advertisement

How to remove a key from inner object through lodash

JavaScript

I want to delete the color key under users. For this, I have written the following code snippet in Lodash.

JavaScript

But it gives me the following { ... }

How can achieve the following output?

JavaScript

Advertisement

Answer

You have to loop over the array and use omit

Arguments of omit is

1) object: The source object.

2) [paths] (…(string|string[])): The property paths to omit.

Return value

(Object): Returns the new object.

JavaScript

Live Demo

Codesandbox Demo

You can easily achieve the result using vanilla JS using map as:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement