MatthewYee92 of Hack Reactor Seattle
6/6/2019 - 5:52 PM

shallowClone

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

const shallowClone = obj => Object.assign({}, obj);

// Examples
const a = { x: true, y: 1 };
const b = shallowClone(a); // a !== b