Merge pull request #1830 from wonderingabout/add-js-formatting
fix missing js formatting
This commit is contained in:
commit
5049c0b7d5
1 changed files with 2 additions and 2 deletions
|
@ -231,7 +231,7 @@ Remember when we talked about `Object.assign()` [in the past](https://javascript
|
||||||
|
|
||||||
It is possible to do the same thing with the spread operator!
|
It is possible to do the same thing with the spread operator!
|
||||||
|
|
||||||
```
|
```js run
|
||||||
let arr = [1, 2, 3];
|
let arr = [1, 2, 3];
|
||||||
let arrCopy = [...arr]; // spread the array into a list of parameters
|
let arrCopy = [...arr]; // spread the array into a list of parameters
|
||||||
// then put the result into a new array
|
// then put the result into a new array
|
||||||
|
@ -250,7 +250,7 @@ alert(arrCopy); // 1, 2, 3
|
||||||
|
|
||||||
Note that it is possible to do the same thing to make a copy of an object:
|
Note that it is possible to do the same thing to make a copy of an object:
|
||||||
|
|
||||||
```
|
```js run
|
||||||
let obj = { a: 1, b: 2, c: 3 };
|
let obj = { a: 1, b: 2, c: 3 };
|
||||||
let objCopy = { ...obj }; // spread the object into a list of parameters
|
let objCopy = { ...obj }; // spread the object into a list of parameters
|
||||||
// then return the result in a new object
|
// then return the result in a new object
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue