Merge pull request #870 from gargakshat/patch-1

Update to improve clarity and avoid confusion.
This commit is contained in:
Ilya Kantor 2019-04-02 14:45:22 +03:00 committed by GitHub
commit 9dff4c05d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -42,19 +42,19 @@ let surname = arr[1];
``` ```
```` ````
````smart header="Ignore first elements" ````smart header="Ignore elements using commas"
Unwanted elements of the array can also be thrown away via an extra comma: Unwanted elements of the array can also be thrown away via an extra comma:
```js run ```js run
*!* *!*
// first and second elements are not needed // second and forth elements are not needed
let [, , title] = ["Julius", "Caesar", "Consul", "of the Roman Republic"]; let [firstName, , title] = ["Julius", "Caesar", "Consul", "of the Roman Republic"];
*/!* */!*
alert( title ); // Consul alert( title ); // Consul
``` ```
In the code above, although the first and second elements of the array are skipped, the third one is assigned to `title`, and the rest are also skipped. In the code above, although thesecond elements of the array is skipped, the third one is assigned to `title`, and the rest are also skipped.
```` ````
````smart header="Works with any iterable on the right-side" ````smart header="Works with any iterable on the right-side"