📜  js 传播排除属性 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:56.185000             🧑  作者: Mango

代码示例1
//// EXCLUDE OBJECT PROPERTY USING THE spread OPERATOR ////

const firstObject = {id: 0, firstName: 'John', age: 77 };
// take every property except age:
const {age, ...secondObject} = firstObject;

console.log(firstObject);
console.log(secondObject);
// { id: 0, firstName: 'John', age: 77 }
// { id: 0, firstName: 'John' }