From b8430d11c650619185b4362c31c8b21153776e3a Mon Sep 17 00:00:00 2001 From: Martijn Arts Date: Sat, 7 Nov 2020 13:41:04 +0100 Subject: [PATCH] Fix explanation saying you can do `=> 5` in JS This claimed you can leave out the parentheses if you have _no_ parameters, which is false. You cannot do `const x = => 5;` --- Week2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week2/README.md b/Week2/README.md index d7f6c5c4c..83dc0525a 100644 --- a/Week2/README.md +++ b/Week2/README.md @@ -143,7 +143,7 @@ const addNum = (num1, num2) => { If you've done some research, you may come to the following conclusions: 1. First of all, the Arrow Function is anonymous by design. If we want to refer to it, we should store it into a variable. -2. Secondly, the way Arrow Functions can be written can differ (while still working the same way). Sometimes you don't need the `()` if there's a single or no parameters. Sometimes you can `return` a value without use for the `return` keyword. +2. Secondly, the way Arrow Functions can be written can differ (while still working the same way). Sometimes you don't need the `()` if there's a single parameter. Sometimes you can `return` a value without use for the `return` keyword. Another big important feature of Arrow Functions (and difference with ES5 functions) is the way they relate to the `this` keyword: instead of creating a new `this` object, it actually inherits it from the parent scope!