Skip to content

Commit 541b7f9

Browse files
authored
Merge pull request #3636 from nakhodkin/patch-5
Fix grammar and JavaScript syntax
2 parents acf339c + b6c604a commit 541b7f9

File tree

1 file changed

+7
-7
lines changed
  • 1-js/05-data-types/10-destructuring-assignment

1 file changed

+7
-7
lines changed

Diff for: 1-js/05-data-types/10-destructuring-assignment/article.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ alert(item1); // Cake
449449
alert(item2); // Donut
450450
```
451451
452-
All properties of `options` object except `extra` that is absent in the left part, are assigned to corresponding variables:
452+
All properties of `options` object except `extra` which is absent in the left part, are assigned to corresponding variables:
453453
454454
![](destructuring-complex.svg)
455455
@@ -459,7 +459,7 @@ Note that there are no variables for `size` and `items`, as we take their conten
459459
460460
## Smart function parameters
461461
462-
There are times when a function has many parameters, most of which are optional. That's especially true for user interfaces. Imagine a function that creates a menu. It may have a width, a height, a title, items list and so on.
462+
There are times when a function has many parameters, most of which are optional. That's especially true for user interfaces. Imagine a function that creates a menu. It may have a width, a height, a title, an item list and so on.
463463
464464
Here's a bad way to write such a function:
465465
@@ -469,7 +469,7 @@ function showMenu(title = "Untitled", width = 200, height = 100, items = []) {
469469
}
470470
```
471471
472-
In real-life, the problem is how to remember the order of arguments. Usually IDEs try to help us, especially if the code is well-documented, but still... Another problem is how to call a function when most parameters are ok by default.
472+
In real-life, the problem is how to remember the order of arguments. Usually, IDEs try to help us, especially if the code is well-documented, but still... Another problem is how to call a function when most parameters are ok by default.
473473
474474
Like this?
475475
@@ -534,7 +534,7 @@ function({
534534
})
535535
```
536536

537-
Then, for an object of parameters, there will be a variable `varName` for property `incomingProperty`, with `defaultValue` by default.
537+
Then, for an object of parameters, there will be a variable `varName` for the property `incomingProperty`, with `defaultValue` by default.
538538

539539
Please note that such destructuring assumes that `showMenu()` does have an argument. If we want all values by default, then we should specify an empty object:
540540

@@ -561,7 +561,7 @@ In the code above, the whole arguments object is `{}` by default, so there's alw
561561
- Destructuring assignment allows for instantly mapping an object or array onto many variables.
562562
- The full object syntax:
563563
```js
564-
let {prop : varName = default, ...rest} = object
564+
let {prop : varName = defaultValue, ...rest} = object
565565
```
566566

567567
This means that property `prop` should go into the variable `varName` and, if no such property exists, then the `default` value should be used.
@@ -571,9 +571,9 @@ In the code above, the whole arguments object is `{}` by default, so there's alw
571571
- The full array syntax:
572572

573573
```js
574-
let [item1 = default, item2, ...rest] = array
574+
let [item1 = defaultValue, item2, ...rest] = array
575575
```
576576

577-
The first item goes to `item1`; the second goes into `item2`, all the rest makes the array `rest`.
577+
The first item goes to `item1`; the second goes into `item2`, and all the rest makes the array `rest`.
578578

579579
- It's possible to extract data from nested arrays/objects, for that the left side must have the same structure as the right one.

0 commit comments

Comments
 (0)