From 05bca6d01cfc457d5202d1335bcca3f019006b2b Mon Sep 17 00:00:00 2001 From: Hannes Leutloff Date: Fri, 16 Nov 2018 20:28:50 +0100 Subject: [PATCH] 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 --- es6.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)