Removes the property at `path` of `object`. **Note:** This method mutates `object`.
const object = { 'a': [{ 'b': { 'c': 7 } }] }
unset(object, 'a[0].b.c')
// => true
console.log(object)
// => { 'a': [{ 'b': {} }] }
unset(object, ['a', '0', 'b', 'c'])
// => true
console.log(object)
// => { 'a': [{ 'b': {} }] }
Name | Type | Attribute | Description |
---|---|---|---|
object | The object to modify. | ||
path | The path of the property to unset. |
{ "comment": "/**\r\n * Removes the property at `path` of `object`.\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 unset.\r\n * @returns {boolean} Returns `true` if the property is deleted, else `false`.\r\n * @see get, has, set\r\n * @example\r\n *\r\n * const object = { 'a': [{ 'b': { 'c': 7 } }] }\r\n * unset(object, 'a[0].b.c')\r\n * // => true\r\n *\r\n * console.log(object)\r\n * // => { 'a': [{ 'b': {} }] }\r\n *\r\n * unset(object, ['a', '0', 'b', 'c'])\r\n * // => true\r\n *\r\n * console.log(object)\r\n * // => { 'a': [{ 'b': {} }] }\r\n */", "meta": { "range": [ 711, 802 ], "filename": "unset.js", "lineno": 29, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100011316", "name": "unset", "type": "FunctionDeclaration", "paramnames": [ "object", "path" ] } }, "description": "Removes the property at `path` of `object`.\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 unset.", "name": "path" } ], "returns": [ { "type": { "names": [ "boolean" ] }, "description": "Returns `true` if the property is deleted, else `false`." } ], "see": [ "get, has, set" ], "examples": [ "const object = { 'a': [{ 'b': { 'c': 7 } }] }\runset(object, 'a[0].b.c')\r// => true\r\rconsole.log(object)\r// => { 'a': [{ 'b': {} }] }\r\runset(object, ['a', '0', 'b', 'c'])\r// => true\r\rconsole.log(object)\r// => { 'a': [{ 'b': {} }] }" ], "name": "unset", "longname": "unset", "kind": "function", "scope": "global", "___id": "T000002R001028", "___s": true, "filepath": "unset.js" }