Skip to content

Commit 5d57a04

Browse files
committed
closes #3111
1 parent 313b174 commit 5d57a04

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,13 @@ function showMessage(from, *!*text = "no text given"*/!*) {
206206
showMessage("Ann"); // Ann: no text given
207207
```
208208
209-
Now if the `text` parameter is not passed, it will get the value `"no text given"`
209+
Now if the `text` parameter is not passed, it will get the value `"no text given"`.
210+
211+
The default value also jumps in if the parameter exists, but strictly equals `undefined`, like this:
212+
213+
```js
214+
showMessage("Ann", undefined); // Ann: no text given
215+
```
210216
211217
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:
212218

0 commit comments

Comments
 (0)