Added info about evaluation of default parameters
See issue #573 for reasoning.
This commit is contained in:
parent
991ca66d70
commit
43b1a82a37
1 changed files with 4 additions and 0 deletions
|
@ -204,6 +204,10 @@ function showMessage(from, text = anotherFunction()) {
|
|||
}
|
||||
```
|
||||
|
||||
```smart header="Evaluation of default parameters"
|
||||
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.
|
||||
```
|
||||
|
||||
|
||||
````smart header="Default parameters old-style"
|
||||
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue