@newdash/newdash
Version:
javascript/typescript utility library
32 lines (31 loc) • 778 B
TypeScript
/**
* Removes the property at `path` of `object`.
*
* **Note:** This method mutates `object`.
*
* @since 5.3.0
* @category Object
* @param object The object to modify.
* @param path The path of the property to unset.
* @returns Returns `true` if the property is deleted, else `false`.
* @see [[get]],[[has]],[[set]]
* @example
*
* ```js
* 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': {} }] }
* ```
*/
export declare function unset<T>(object: T, path: Array<string>): T;
export declare function unset<T>(object: T, path: string): T;
export default unset;