The omit
function from Lodash is used to create a new object with all properties from the original object except for the ones specified to be omitted. Here's how to use it:
index.tsx236 chars14 lines
In this example, we first import the Lodash library using the require()
function. We then create an object called originalObj
with four properties: name
, age
, city
, and country
. We then use _.omit()
to create a new object called newObj
with all the properties of originalObj
except for city
and country
. We pass _.omit()
an array of property names to omit.
The output of console.log(newObj)
is { name: 'John', age: 30 }
, which is the originalObj
with city
and country
removed.
gistlibby LogSnag