I have a javascript object like this:
let obj = {
foo: "bar",
baz: "quux",
banana: "apple"
}
And i want another object containing all the properties in obj
but one, something like
{
foo: "bar",
banana: "apple"
}
I don't want to change obj
, so using delete
is not an option, and i'd also like to avoid writing a function that loops on Object.keys
and sets all properties but baz
to a new object.
Is there a native function to do something like this, basically like a slice
for objects?