Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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)

AltStyle によって変換されたページ (->オリジナル) /