You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
606 B
25 lines
606 B
/** |
|
* Checks `value` to determine whether a default value should be returned in |
|
* its place. The `defaultValue` is returned if `value` is `NaN`, `null`, |
|
* or `undefined`. |
|
* |
|
* @static |
|
* @memberOf _ |
|
* @since 4.14.0 |
|
* @category Util |
|
* @param {*} value The value to check. |
|
* @param {*} defaultValue The default value. |
|
* @returns {*} Returns the resolved value. |
|
* @example |
|
* |
|
* _.defaultTo(1, 10); |
|
* // => 1 |
|
* |
|
* _.defaultTo(undefined, 10); |
|
* // => 10 |
|
*/ |
|
function defaultTo(value, defaultValue) { |
|
return (value == null || value !== value) ? defaultValue : value; |
|
} |
|
|
|
export default defaultTo;
|
|
|