If we want to remove any key from a given object then we have the following method.
1. Using delete
const obj = { a: 1, b: 2, c: 3, d:{ e:2, f:4 } }; delete obj.a; OR delete obj['a'] console.log(obj); // { b: 2, c: 3, d:{ e:2, f:4 } }
2. Using rest parameter
const obj = { a: 1, b: 2, c: 3, d:{ e:2, f:4 } }; const {a, ...newObj} = obj console.log(newObj) // { b: 2, c: 3, d:{ e:2, f:4 } }