复制并且排除 Posted on 2021-01-24 12var clone = Object.assign({}, {a: 1, b: 2, c: 3});delete clone.b; 这个不完美 1var clone2 = Object.assign({}, {a: 1, b: 2, c: 3}, {b: undefined}); 123456789const x = {a: 1, b: 2, c: 3, z:26};const objectWithoutKey = (object, key) => { const {[key]: deletedKey, ...otherKeys} = object; return otherKeys;}console.log(objectWithoutKey(x, 'b')); // {a: 1, c: 3, z:26}console.log(x); // {a: 1, b: 2, c: 3, z:26}; 123const obj = { a: 1, b: 2, c: 3, d: 4 }const clone = (({ b, c, ...o }) => o)(obj) // remove b and cconsole.log(clone) lodash 1_.omit(x, 'b')