Files
30-seconds-of-code/snippets/shallowClone.md
Angelos Chalaris bb722b2eb4 Updated examples
2017-12-27 16:35:25 +02:00

296 B

shallowClone

Creates a shallow clone of an object.

Use Object.assign() and an empty object ({}) to create a shallow clone of the original.

const shallowClone = obj => Object.assign({}, obj);
const a = { x: true, y: 1 };
const b = shallowClone(a);
a === b // false