Omit
Creates a new object with specified keys omitted.
Category | Objects |
Author | Pol Gubau |
Since | 1.0.0 |
Last Updated | 2025-03-15 |
Type | Sync |
Compatibility | Universal |
Example
Input
const obj = { a: 1, b: 2, c: 3 }; const result = omit(obj, ['b', 'c']);
Output:
{ a: 1 }
Return
A new object with the specified keys omitted.
Type: Omit<T, K>
Props
Name | Type | Default | Required | Description |
---|---|---|---|---|
obj | T extends Record<string, any> | null | Yes | The object to omit keys from. |
keys | K[] | null | Yes | An array of keys to be omitted from the object. |
Notes
This function creates a shallow copy of the provided object and deletes the properties specified by the `keys` array. It does not modify the original object. If a key is not present in the object, it is simply ignored without causing any errors.
Tags
- omit
- object
- manipulation
- exclude
- keys
Related
- arrays
- universal
- sync
- Since 1.0.0
- validations
- universal
- sync
- Since 1.0.0
- objects
- universal
- sync
- Since 1.0.0
groupBy
Groups the elements of an array based on a provided key-generating function.
isObject
Checks if the provided parameter is a plain object.
cloneDeep
Deep clone an object. A deep clone is a clone of the source object and all of its children, and their children, and so on.