Merge pull request #269 from usernamehw/patch-16

Update article.md
This commit is contained in:
Ilya Kantor 2017-11-01 10:46:20 +03:00 committed by GitHub
commit 42ca672a5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -136,7 +136,7 @@ alert(rest.length); // 2
*/!*
```
The value of `rest` is the array of the remaining array elements. We can use any other variable name in place of `rest`, just make sure it has three dots before it and goes last in the destructuring assignmemnt.
The value of `rest` is the array of the remaining array elements. We can use any other variable name in place of `rest`, just make sure it has three dots before it and goes last in the destructuring assignment.
### Default values
@ -434,7 +434,7 @@ let options = {
function showMenu(*!*{title = "Untitled", width = 200, height = 100, items = []}*/!*) {
// title, items taken from options,
// width, height defaults used
alert( title + ' ' + width + ' ' + height ); // My Menu 100 200
alert( `${title} ${width} ${height}` ); // My Menu 200 100
alert( items ); // Item1, Item2
}
@ -457,7 +457,7 @@ function showMenu({
items: [item1, item2] // items first element goes to item1, second to item2
}) {
*/!*
alert( title + ' ' + w + ' ' + h ); // My Menu 100 200
alert( `${title} ${w} ${h}` ); // My Menu 100 200
alert( item1 ); // Item1
alert( item2 ); // Item2
}
@ -488,7 +488,7 @@ We can fix this by making `{}` the default value for the whole destructuring thi
```js run
// simplified parameters a bit for clarity
function showMenu(*!*{ title = "Menu", width = 100, height = 200 } = {}*/!*) {
alert( title + ' ' + width + ' ' + height );
alert( `${title} ${width} ${height}` );
}
showMenu(); // Menu 100 200