Fully renamed and updated everything, tagged, built
This commit is contained in:
14
snippets/shallowClone.md
Normal file
14
snippets/shallowClone.md
Normal file
@ -0,0 +1,14 @@
|
||||
### shallowClone
|
||||
|
||||
Creates a shallow clone of an 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
|
||||
*/
|
||||
```
|
||||
Reference in New Issue
Block a user