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 471371e

Browse files
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‎

Lines changed: 4 additions & 0 deletions
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)

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