Omit

Creates a new object with specified keys omitted.

CategoryObjects
AuthorPol Gubau
Since1.0.0
Last Updated2025-03-15
TypeSync
CompatibilityUniversal

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

NameTypeDefaultRequiredDescription
objT extends Record<string, any>nullYesThe object to omit keys from.
keysK[]nullYesAn 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