Merge branch 'pr-413'

* pr-413:
  es6: shorten destructuring example
  Use consistent single quotes
  Add default values example for destructured function arguments
This commit is contained in:
Rico Sta. Cruz 2018-03-17 13:33:22 +08:00
commit 41d2baa052
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 14 additions and 0 deletions

14
es6.md
View File

@ -232,6 +232,20 @@ greet({ name: 'Larry', greeting: 'Ahoy' })
Destructuring of objects and arrays can be also be done in function arguments. Destructuring of objects and arrays can be also be done in function arguments.
### Default values
```js
function greet({ name = 'Rauno' } = {}) {
console.log(`Hi ${name}!`);
}
```
{: data-line="1"}
```js
greet() // Hi Rauno!
greet({ name: 'Larry' }) // Hi Larry!
```
### Reassigning keys ### Reassigning keys
```js ```js