You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/15-function-expressions-arrows/article.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -78,8 +78,8 @@ let func = sayHi;
78
78
Everything would work the same. Even more obvious what's going on, right?
79
79
80
80
81
-
````smart header="Why there's a semicolon at the end?"
82
-
There might be a question, why does Function Expression have a semicolon `;` at the end, and Function Declaration does not:
81
+
````smart header="Why is there a semicolon at the end?"
82
+
You might wonder, why does Function Expression have a semicolon `;` at the end, but Function Declaration does not:
83
83
84
84
```js
85
85
function sayHi() {
@@ -198,7 +198,7 @@ The more subtle difference is *when* a function is created by the JavaScript eng
198
198
199
199
**A Function Expression is created when the execution reaches it and is usable from then on.**
200
200
201
-
Once the execution flow passes to the right side of the assignment `let sum = function…` -- here we go, the function is created and can be used (assigned, calledetc) from now on.
201
+
Once the execution flow passes to the right side of the assignment `let sum = function…` -- here we go, the function is created and can be used (assigned, called,etc. ) from now on.
202
202
203
203
Function Declarations are different.
204
204
@@ -350,7 +350,7 @@ welcome(); // ok now
350
350
```
351
351
352
352
353
-
```smart header="When to choose Function Declaration versus Function Expression?"
353
+
```smart header="When should you choose Function Declaration versus Function Expression?"
354
354
As a rule of thumb, when we need to declare a function, the first to consider is Function Declaration syntax, the one we used before. It gives more freedom in how to organize our code, because we can call such functions before they are declared.
355
355
356
356
It's also a little bit easier to look up `function f(…) {…}` in the code than `let f = function(…) {…}`. Function Declarations are more "eye-catching".
0 commit comments