To delete property from spread operator with JavaScript, we use the rest syntax.
For instance, we write
const myObject = {
a: 1,
b: 2,
c: 3,
};
const { b, ...noB } = myObject;
console.log(noB);
to use the rest syntax to get all the properties except b
from myObject
.
b
is destructured earlier, so it’ll be omitted from noB
.