Is the spread operator have the exception feature? like:
originalObject = {
key1: '',
key2: '',
key3: ''
}
const clonedOriginalObject = {
...object,
// except key2
}
So what I'm excepting is the clonedObject
contains only key1 and key2
you can use Destructuring_assignment to omit key2
and get the rest
:
originalObject = {
key1: "",
key2: "",
key3: ""
};
const { key2, ...clonedOriginalObject } = originalObject;
console.log(clonedOriginalObject);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With