Skip to content

Function: omit()

ts
function omit<T, K>(object, keys): Omit<T, K>;

Creates a new object without the specified keys. 创建一个移除指定键的新对象。

Type Parameters

Type ParameterDescription
T extends Record<PropertyKey, unknown>The source object type / 源对象类型
K extends string | number | symbolThe omitted key type / 要移除的键类型

Parameters

ParameterTypeDescription
objectTThe source object / 源对象
keysreadonly K[]The keys to omit / 要移除的键

Returns

Omit<T, K>

A new object without the omitted keys / 移除指定键后的新对象

Example

ts
omit({ a: 1, b: 2, c: 3 }, ['b'])
// => { a: 1, c: 3 }

Since

1.2.0

Released under the MIT License.