This method is like `set` except that it accepts `customizer` which is invoked to produce the objects of `path`. If `customizer` returns `undefined` path creation is handled by the method instead. The `customizer` is invoked with three arguments: (nsValue, key, nsObject). **Note:** This method mutates `object`.
const object = {}
setWith(object, '[0][1]', 'a', Object)
// => { '0': { '1': 'a' } }
Name | Type | Attribute | Description |
---|---|---|---|
object | The object to modify. | ||
path | The path of the property to set. | ||
value | The value to set. | ||
customizer | The function to customize assigned values. |
{ "comment": "/**\r\n * This method is like `set` except that it accepts `customizer` which is\r\n * invoked to produce the objects of `path`. If `customizer` returns `undefined`\r\n * path creation is handled by the method instead. The `customizer` is invoked\r\n * with three arguments: (nsValue, key, nsObject).\r\n *\r\n * **Note:** This method mutates `object`.\r\n *\r\n * @since 4.0.0\r\n * @category Object\r\n * @param {Object} object The object to modify.\r\n * @param {Array|string} path The path of the property to set.\r\n * @param {*} value The value to set.\r\n * @param {Function} [customizer] The function to customize assigned values.\r\n * @returns {Object} Returns `object`.\r\n * @example\r\n *\r\n * const object = {}\r\n *\r\n * setWith(object, '[0][1]', 'a', Object)\r\n * // => { '0': { '1': 'a' } }\r\n */", "meta": { "range": [ 825, 1029 ], "filename": "setWith.js", "lineno": 25, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100008089", "name": "setWith", "type": "FunctionDeclaration", "paramnames": [ "object", "path", "value", "customizer" ] }, "vars": { "customizer": "setWith~customizer" } }, "description": "This method is like `set` except that it accepts `customizer` which is\rinvoked to produce the objects of `path`. If `customizer` returns `undefined`\rpath creation is handled by the method instead. The `customizer` is invoked\rwith three arguments: (nsValue, key, nsObject).\r\r**Note:** This method mutates `object`.", "since": "4.0.0", "tags": [ { "originalTitle": "category", "title": "category", "text": "Object", "value": "Object" } ], "params": [ { "type": { "names": [ "Object" ] }, "description": "The object to modify.", "name": "object" }, { "type": { "names": [ "Array", "string" ] }, "description": "The path of the property to set.", "name": "path" }, { "type": { "names": [ "*" ] }, "description": "The value to set.", "name": "value" }, { "type": { "names": [ "function" ] }, "optional": true, "description": "The function to customize assigned values.", "name": "customizer" } ], "returns": [ { "type": { "names": [ "Object" ] }, "description": "Returns `object`." } ], "examples": [ "const object = {}\r\rsetWith(object, '[0][1]', 'a', Object)\r// => { '0': { '1': 'a' } }" ], "name": "setWith", "longname": "setWith", "kind": "function", "scope": "global", "___id": "T000002R000744", "___s": true, "filepath": "setWith.js" }