Function: omit()
ts
function omit<T, K>(object, keys): Omit<T, K>;Creates a new object without the specified keys. 创建一个移除指定键的新对象。
Type Parameters
| Type Parameter | Description |
|---|---|
T extends Record<PropertyKey, unknown> | The source object type / 源对象类型 |
K extends string | number | symbol | The omitted key type / 要移除的键类型 |
Parameters
| Parameter | Type | Description |
|---|---|---|
object | T | The source object / 源对象 |
keys | readonly 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