Skip to content

Commit 4585dbb

Browse files
committed
minor fixes
1 parent 741d90c commit 4585dbb

File tree

1 file changed

+5
-5
lines changed
  • 1-js/02-first-steps/17-arrow-functions-basics

1 file changed

+5
-5
lines changed

1-js/02-first-steps/17-arrow-functions-basics/article.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ As you can see, `(a, b) => a + b` means a function that accepts two arguments na
4848
alert( double(3) ); // 6
4949
```
5050

51-
- If there are no arguments, parentheses will be empty (but they should be present):
51+
- If there are no arguments, parentheses are empty, but they must be present:
5252

5353
```js run
5454
let sayHi = () => alert("Hello!");
@@ -76,9 +76,9 @@ They are very convenient for simple one-line actions, when we're just too lazy t
7676
7777
## Multiline arrow functions
7878
79-
The examples above took arguments from the left of `=>` and evaluated the right-side expression with them.
79+
The arrow functions that we've seen so far were very simple. They took arguments from the left of `=>`, evaluated and returned the right-side expression with them.
8080

81-
Sometimes we need something a little bit more complex, like multiple expressions or statements. It is also possible, but we should enclose them in curly braces. Then use a normal `return` within them.
81+
Sometimes we need a more complex function, with multiple expressions and statements. In that case, but we can enclose them in curly braces. The major difference is that curly braces require a `return` within them to return a value (just like a regular function does).
8282

8383
Like this:
8484

@@ -105,7 +105,7 @@ For now, we can already use arrow functions for one-line actions and callbacks.
105105
106106
## Summary
107107
108-
Arrow functions are handy for one-liners. They come in two flavors:
108+
Arrow functions are handy for simple actions, especially for one-liners. They come in two flavors:
109109
110-
1. Without curly braces: `(...args) => expression` -- the right side is an expression: the function evaluates it and returns the result.
110+
1. Without curly braces: `(...args) => expression` -- the right side is an expression: the function evaluates it and returns the result. Parentheses can be omitted, if there's only a single argument, e.g. `n => n*2`.
111111
2. With curly braces: `(...args) => { body }` -- brackets allow us to write multiple statements inside the function, but we need an explicit `return` to return something.

0 commit comments

Comments
 (0)