Update es6.md (#709)
* Update es6.md Add edge case of implicitly returned object, since the notation is a little different. * Update es6.md: fix typo
This commit is contained in:
parent
41c619d50d
commit
05bca6d01c
6
es6.md
6
es6.md
|
@ -385,8 +385,12 @@ readFile('text.txt', (err, data) => {
|
||||||
numbers.map(n => n * 2)
|
numbers.map(n => n * 2)
|
||||||
// No curly braces = implicit return
|
// No curly braces = implicit return
|
||||||
// Same as: numbers.map(function (n) { return n * 2 })
|
// Same as: numbers.map(function (n) { return n * 2 })
|
||||||
|
numbers.map(n => ({
|
||||||
|
result: n * 2
|
||||||
|
})
|
||||||
|
// Implicitly returning objects requires parentheses around the object
|
||||||
```
|
```
|
||||||
{: data-line="1"}
|
{: data-line="1,4,5,6"}
|
||||||
|
|
||||||
Like functions but with `this` preserved.
|
Like functions but with `this` preserved.
|
||||||
See: [Fat arrows](https://babeljs.io/learn-es2015/#arrows-and-lexical-this)
|
See: [Fat arrows](https://babeljs.io/learn-es2015/#arrows-and-lexical-this)
|
||||||
|
|
Loading…
Reference in New Issue