Skip to content

omit

The omit function creates a copy of an object, excluding the specified properties.

Syntax

typescript
omit(obj, keys): object

Parameters

NameTypeDescription
objobjectSource object.
keysstring[]List of keys to omit.

Return

TypeDescription
objectReturns a new object without the properties specified in keys.

Examples

typescript
omit({ a: 1, b: 2, c: 3 }, ['b']); // { a: 1, c: 3 }
omit({ x: 10, y: 20 }, ['x']); // { y: 20 }

Notes

  • Does not modify the original object.
  • Useful for removing sensitive or unnecessary properties.

References

Released under the MIT License.