refactor arrow functions

This commit is contained in:
Ilya Kantor 2019-11-06 14:52:58 +03:00
parent 6165a9a727
commit 2aedc2df49

View file

@ -86,7 +86,7 @@ Like this:
let sum = (a, b) => { // the curly brace opens a multiline function
let result = a + b;
*!*
return result; // if we use curly braces, use return to get results
return result; // if we use curly braces, then we need an explicit "return"
*/!*
};
@ -94,7 +94,11 @@ alert( sum(1, 2) ); // 3
```
```smart header="More to come"
Here we praised arrow functions for brevity. But that's not all! Arrow functions have other interesting features. We'll return to them later in the chapter <info:arrow-functions>.
Here we praised arrow functions for brevity. But that's not all!
Arrow functions have other interesting features.
To study them in-depth, we first need to get to know some other aspects of JavaScript, so we'll return to arrow functions later in the chapter <info:arrow-functions>.
For now, we can already use arrow functions for one-line actions and callbacks.
```