2024-04-25 14:56:13 +03:00
|
|
|
# omit
|
|
|
|
|
|
|
|
Creates a new object with specified keys omitted.
|
|
|
|
|
2024-06-04 11:19:26 +03:00
|
|
|
This function takes an object and an array of keys, and returns a new object that
|
2024-04-25 14:56:13 +03:00
|
|
|
excludes the properties corresponding to the specified keys.
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
|
|
|
```typescript
|
2024-06-12 09:22:16 +03:00
|
|
|
function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
2024-04-25 14:56:13 +03:00
|
|
|
```
|
|
|
|
|
2024-06-04 11:19:26 +03:00
|
|
|
### Parameters
|
2024-04-25 14:56:13 +03:00
|
|
|
|
|
|
|
- `obj` (`T`): The object to omit keys from.
|
|
|
|
- `keys` (`K[]`): An array of keys to be omitted from the object.
|
|
|
|
|
|
|
|
### Returns
|
|
|
|
|
|
|
|
(`Omit<T, K>`): A new object with the specified keys omitted.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
const obj = { a: 1, b: 2, c: 3 };
|
|
|
|
const result = omit(obj, ['b', 'c']);
|
|
|
|
// result will be { a: 1 }
|
|
|
|
```
|