closes #3111
This commit is contained in:
parent
313b174bf1
commit
5d57a04b66
1 changed files with 7 additions and 1 deletions
|
@ -206,7 +206,13 @@ function showMessage(from, *!*text = "no text given"*/!*) {
|
||||||
showMessage("Ann"); // Ann: no text given
|
showMessage("Ann"); // Ann: no text given
|
||||||
```
|
```
|
||||||
|
|
||||||
Now if the `text` parameter is not passed, it will get the value `"no text given"`
|
Now if the `text` parameter is not passed, it will get the value `"no text given"`.
|
||||||
|
|
||||||
|
The default value also jumps in if the parameter exists, but strictly equals `undefined`, like this:
|
||||||
|
|
||||||
|
```js
|
||||||
|
showMessage("Ann", undefined); // Ann: no text given
|
||||||
|
```
|
||||||
|
|
||||||
Here `"no text given"` is a string, but it can be a more complex expression, which is only evaluated and assigned if the parameter is missing. So, this is also possible:
|
Here `"no text given"` is a string, but it can be a more complex expression, which is only evaluated and assigned if the parameter is missing. So, this is also possible:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue