Skip to content

Commit 5886ac3

Browse files
authored
Merge pull request #622 from mathiasbockwoldt/patch-1
Added info about evaluation of default parameters
2 parents 97528aa + 43b1a82 commit 5886ac3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

1-js/02-first-steps/14-function-basics/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ function showMessage(from, text = anotherFunction()) {
204204
}
205205
```
206206
207+
```smart header="Evaluation of default parameters"
208+
In JavaScript, a default parameter is evaluated every time the function is called without the respective parameter. In the example above, `anotherFunctions()` is called everytime `someMessage()` is called without the `text` parameter. This is in contrast to some other languages like Python, where any default parameters are evaluated only once during the initial interpretation.
209+
```
210+
207211

208212
````smart header="Default parameters old-style"
209213
Old editions of JavaScript did not support default parameters. So there are alternative ways to support them, that you can find mostly in the old scripts.

0 commit comments

Comments
 (0)