Files
30-seconds-of-code/snippets/shallow-clone-object.md
2017-12-14 23:27:27 +02:00

13 lines
256 B
Markdown

### Shallow clone object
Use the object `...spread` operator to spread the properties of the target object into the clone.
```js
const shallowClone = obj => ({ ...obj });
/*
const a = { x: true, y: 1 };
const b = shallowClone(a);
a === b -> false
*/
```