Assigns own and inherited enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to `undefined`. Source objects are applied from left to right. Once a property is set, additional values of the same property are ignored. **Note:** This method mutates `object`.
defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 })
// => { 'a': 1, 'b': 2 }
| Name | Type | Attribute | Description |
|---|---|---|---|
| object | The destination object. | ||
| sources | The source objects. |
{
"comment": "/**\r\n * Assigns own and inherited enumerable string keyed properties of source\r\n * objects to the destination object for all destination properties that\r\n * resolve to `undefined`. Source objects are applied from left to right.\r\n * Once a property is set, additional values of the same property are ignored.\r\n *\r\n * **Note:** This method mutates `object`.\r\n *\r\n * @since 0.1.0\r\n * @category Object\r\n * @param {Object} object The destination object.\r\n * @param {...Object} [sources] The source objects.\r\n * @returns {Object} Returns `object`.\r\n * @see defaultsDeep\r\n * @example\r\n *\r\n * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 })\r\n * // => { 'a': 1, 'b': 2 }\r\n */",
"meta": {
"range": [
933,
1535
],
"filename": "defaults.js",
"lineno": 29,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100001573",
"name": "defaults",
"type": "FunctionDeclaration",
"paramnames": [
"object",
"sources"
]
},
"vars": {
"object": "defaults~object",
"srcIndex": "defaults~srcIndex",
"srcLength": "defaults~srcLength",
"source": "defaults~source",
"props": "defaults~props",
"propsIndex": "defaults~propsIndex",
"propsLength": "defaults~propsLength",
"key": "defaults~key",
"value": "defaults~value",
"object[undefined]": "defaults~object.undefined]"
}
},
"description": "Assigns own and inherited enumerable string keyed properties of source\robjects to the destination object for all destination properties that\rresolve to `undefined`. Source objects are applied from left to right.\rOnce a property is set, additional values of the same property are ignored.\r\r**Note:** This method mutates `object`.",
"since": "0.1.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "Object",
"value": "Object"
}
],
"params": [
{
"type": {
"names": [
"Object"
]
},
"description": "The destination object.",
"name": "object"
},
{
"type": {
"names": [
"Object"
]
},
"optional": true,
"variable": true,
"description": "The source objects.",
"name": "sources"
}
],
"returns": [
{
"type": {
"names": [
"Object"
]
},
"description": "Returns `object`."
}
],
"see": [
"defaultsDeep"
],
"examples": [
"defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 })\r// => { 'a': 1, 'b': 2 }"
],
"name": "defaults",
"longname": "defaults",
"kind": "function",
"scope": "global",
"___id": "T000002R000183",
"___s": true,
"filepath": "defaults.js"
}