You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/15-function-basics/article.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -206,7 +206,13 @@ function showMessage(from, *!*text = "no text given"*/!*) {
206
206
showMessage("Ann"); // Ann: no text given
207
207
```
208
208
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
+
```
210
216
211
217
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:
0 commit comments