Skip to content

Commit 471371e

Browse files
committed
Add note about default arguments
1 parent 348760e commit 471371e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ function paintCar(car) {
176176
**[⬆ back to top](#table-of-contents)**
177177

178178
### Use default arguments instead of short circuiting or conditionals
179+
Default arguments are often cleaner than short circuiting. Be aware that if you
180+
use them, your function will only provide default values for `undefined`
181+
arguments. Other "falsy" values such as `''`, `""`, `false`, `null`, `0`, and
182+
`NaN`, will not be replaced by a default value.
179183

180184
**Bad:**
181185
```javascript

0 commit comments

Comments
 (0)