Skip to content

Commit 830e89f

Browse files
committed
null vs undefined
1 parent ddcd83b commit 830e89f

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Javascript/Tricky-JS-Problems/null-vs-undefined.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,24 @@ let logHi = (str = "hi") => {
5555
```
5656

5757
The code above creates a function named logHi. This function requires one parameter and sets the default of that parameter to hi if it isn’t supplied. Here’s what that looks like:
58-
logHi();
58+
59+
```js
60+
logHi()
61+
// hi
62+
```
63+
64+
We can also supply a parameter to overwrite this default:
65+
66+
```js
67+
logHi("bye")
68+
// bye
69+
```
70+
71+
With default parameters, undefined will use the default while null does not.
72+
73+
```js
74+
logHi(undefined)
5975
// hi
76+
logHi(null)
77+
// null
78+
```

0 commit comments

Comments
 (0)