Documentation / @andrew_l/toolkit / omit
Function: omit()
omit<
T
,U
>(obj
,excludes
):Omit
<T
,U
>
Creates a new object with specified keys omitted.
This function takes an object and an array of keys, and returns a new object that excludes the properties corresponding to the specified keys.
Type Parameters
• T extends Record
<string
, any
>
The type of object.
• U extends string
| number
| symbol
Parameters
• obj: T
The object to omit keys from.
• excludes: Readonly
<string
[] | Set
<string
> | U
[] | Set
<U
>>
Returns
Omit
<T
, U
>
A new object with the specified keys omitted.
Example
ts
const obj = { a: 1, b: 2, c: 3 };
const result = omit(obj, ['b', 'c']);
// result will be { a: 1 }