Travis build: 2050
This commit is contained in:
@ -7,8 +7,6 @@ Use `Object.assign()` and an empty object (`{}`) to create a shallow clone of th
|
||||
Use `Object.keys()` and `Array.forEach()` to determine which key-value pairs need to be deep cloned.
|
||||
|
||||
```js
|
||||
|
||||
|
||||
const deepClone = obj => {
|
||||
let clone = Object.assign({}, obj);
|
||||
Object.keys(clone).forEach(
|
||||
@ -19,10 +17,6 @@ const deepClone = obj => {
|
||||
```
|
||||
|
||||
```js
|
||||
|
||||
|
||||
|
||||
|
||||
const a = { foo: 'bar', obj: { a: 1, b: 2 } };
|
||||
const b = deepClone(a); // a !== b, a.obj !== b.obj
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user