Skip to content

Commit 5c92a9a

Browse files
authored
prefer-default-parameters - Document falsy values (#2423)
1 parent 77f32e5 commit 5c92a9a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/rules/prefer-default-parameters.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
Instead of reassigning a function parameter, default parameters should be used. The `foo = foo || 123` statement evaluates to `123` when `foo` is falsy, possibly leading to confusing behavior, whereas default parameters only apply when passed an `undefined` value. This rule only reports reassignments to literal values.
1111

12+
You should disable this rule if you want your functions to deal with `null` and other falsy values the same way as `undefined`. Default parameters are exclusively applied [when `undefined` is received.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters#passing_undefined_vs._other_falsy_values). However, we recommend [moving away from `null`](https://github.com/sindresorhus/meta/discussions/7).
13+
1214
## Fail
1315

1416
```js

0 commit comments

Comments
 (0)