From b64b07e656781e8671e97f1724061afd9f3db923 Mon Sep 17 00:00:00 2001 From: Filip Barakovski Date: Tue, 15 Jan 2019 05:54:31 +0100 Subject: [PATCH] Answers an arrow function use case question (#145) * Answers an arrow function use case question ### Can you offer a use case for the new arrow => function syntax? How does this new syntax differ from other functions? * Update javascript-questions.md * Update javascript-questions.md --- questions/javascript-questions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/questions/javascript-questions.md b/questions/javascript-questions.md index 7acefd26e..f1d2fd936 100644 --- a/questions/javascript-questions.md +++ b/questions/javascript-questions.md @@ -1029,7 +1029,7 @@ It's much more verbose to use inheritance in ES5 and the ES6 version is easier t ### Can you offer a use case for the new arrow => function syntax? How does this new syntax differ from other functions? -TODO +One obvious benefit of arrow functions is to simplify the syntax needed to create functions, without a need for the `function` keyword. The `this` within arrow functions is also bound to the enclosing scope which is different compared to regular functions where the `this` is determined by the object calling it. Lexically-scoped `this` is useful when invoking callbacks especially in React components. [[↑] Back to top](#js-questions)