Skip to content

Function: unset() ​

ts
function unset(object, path): boolean;

Removes a nested property from an object by path. 通过路径删除对象中的嵌套属性。

Parameters ​

ParameterTypeDescription
objectRecord<PropertyKey, unknown>The target object / 目标对象
pathstring | readonly PropertyKey[]The delete path / 删除路径

Returns ​

boolean

true when the property existed and was removed / 属性存在并被删除时返回 true

Example ​

ts
unset({ a: { b: 1 } }, 'a.b')
// => true

Since ​

1.2.0

Released under the MIT License.