Files
30-seconds-of-code/snippets/shallow-clone.md
Stefan Feješ b848906fe5 fix naming
2017-12-17 15:41:31 +01:00

13 lines
260 B
Markdown

### Shallow clone object
Use `Object.assign()` and an empty object (`{}`) to create a shallow clone of the original.
```js
const shallowClone = obj => Object.assign({}, obj);
/*
const a = { x: true, y: 1 };
const b = shallowClone(a);
a === b -> false
*/
```