root / HServer / 00.Server / 00.Program / node_modules / lodash / defaultTo.js
이력 | 보기 | 이력해설 | 다운로드 (608 Bytes)
| 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 |
module.exports = defaultTo; |