Skip to content

Commit db55cf7

Browse files
authored
Update to improve clarity and avoid confusion.
Changing the section on using commas to skip array elements, so as to make it more explicit that the skipping is possible for the elements in the middle of the array as well. The code sample and smart-heading give the impression that only the first elements can be skipped.
1 parent 706b1f2 commit db55cf7

File tree

1 file changed

+4
-4
lines changed
  • 1-js/05-data-types/09-destructuring-assignment

1 file changed

+4
-4
lines changed

1-js/05-data-types/09-destructuring-assignment/article.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ let surname = arr[1];
4242
```
4343
````
4444

45-
````smart header="Ignore first elements"
45+
````smart header="Ignore elements using commas"
4646
Unwanted elements of the array can also be thrown away via an extra comma:
4747
4848
```js run
4949
*!*
50-
// first and second elements are not needed
51-
let [, , title] = ["Julius", "Caesar", "Consul", "of the Roman Republic"];
50+
// second and forth elements are not needed
51+
let [firstName, , title] = ["Julius", "Caesar", "Consul", "of the Roman Republic"];
5252
*/!*
5353
5454
alert( title ); // Consul
5555
```
5656
57-
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.
57+
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.
5858
````
5959

6060
````smart header="Works with any iterable on the right-side"

0 commit comments

Comments
 (0)