main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
606 bytes
|
Line | |
---|
1 | /**
|
---|
2 | * Checks `value` to determine whether a default value should be returned in
|
---|
3 | * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
|
---|
4 | * or `undefined`.
|
---|
5 | *
|
---|
6 | * @static
|
---|
7 | * @memberOf _
|
---|
8 | * @since 4.14.0
|
---|
9 | * @category Util
|
---|
10 | * @param {*} value The value to check.
|
---|
11 | * @param {*} defaultValue The default value.
|
---|
12 | * @returns {*} Returns the resolved value.
|
---|
13 | * @example
|
---|
14 | *
|
---|
15 | * _.defaultTo(1, 10);
|
---|
16 | * // => 1
|
---|
17 | *
|
---|
18 | * _.defaultTo(undefined, 10);
|
---|
19 | * // => 10
|
---|
20 | */
|
---|
21 | function defaultTo(value, defaultValue) {
|
---|
22 | return (value == null || value !== value) ? defaultValue : value;
|
---|
23 | }
|
---|
24 |
|
---|
25 | export default defaultTo;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.