diff --git a/es6.md b/es6.md index 37bf9c5fa..1d0ec6a27 100644 --- a/es6.md +++ b/es6.md @@ -385,8 +385,12 @@ readFile('text.txt', (err, data) => { numbers.map(n => n * 2) // No curly braces = implicit return // 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. See: [Fat arrows](https://babeljs.io/learn-es2015/#arrows-and-lexical-this)