Merge pull request #137 from atomiks/patch-4

Create shallow-clone-object.md
This commit is contained in:
Angelos Chalaris
2017-12-14 23:27:35 +02:00
committed by GitHub

View File

@ -0,0 +1,12 @@
### 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
*/
```