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`.
defaultTo(1, 10)
// => 1
defaultTo(undefined, 10)
// => 10
Name | Type | Attribute | Description |
---|---|---|---|
value | The value to check. | ||
defaultValue | The default value. |
*
{ "comment": "/**\r\n * Checks `value` to determine whether a default value should be returned in\r\n * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,\r\n * or `undefined`.\r\n *\r\n * @since 4.14.0\r\n * @category Util\r\n * @param {*} value The value to check.\r\n * @param {*} defaultValue The default value.\r\n * @returns {*} Returns the resolved value.\r\n * @example\r\n *\r\n * defaultTo(1, 10)\r\n * // => 1\r\n *\r\n * defaultTo(undefined, 10)\r\n * // => 10\r\n */", "meta": { "range": [ 453, 565 ], "filename": "defaultTo.js", "lineno": 19, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100001706", "name": "defaultTo", "type": "FunctionDeclaration", "paramnames": [ "value", "defaultValue" ] } }, "description": "Checks `value` to determine whether a default value should be returned in\rits place. The `defaultValue` is returned if `value` is `NaN`, `null`,\ror `undefined`.", "since": "4.14.0", "tags": [ { "originalTitle": "category", "title": "category", "text": "Util", "value": "Util" } ], "params": [ { "type": { "names": [ "*" ] }, "description": "The value to check.", "name": "value" }, { "type": { "names": [ "*" ] }, "description": "The default value.", "name": "defaultValue" } ], "returns": [ { "type": { "names": [ "*" ] }, "description": "Returns the resolved value." } ], "examples": [ "defaultTo(1, 10)\r// => 1\r\rdefaultTo(undefined, 10)\r// => 10" ], "name": "defaultTo", "longname": "defaultTo", "kind": "function", "scope": "global", "___id": "T000002R000197", "___s": true, "filepath": "defaultTo.js" }