Skip to main content

omit

Returns a new object based on the first argument object, omitting the properties corresponding to the elements of the keys array passed as the second argument.

The returned object is a deep-copied new object.


Code

🔗 View source code

Benchmark

  • hz: operations per second
  • mean: average response time (ms)
NamehzmeanPerformance
modern-kit/omit1,505,400.160.0003fastest
lodash/omit901,269.430.0011slowest
  • modern-kit/omit
    • 1.67x faster than lodash/omit

Interface

typescript
function omit<T extends Record<PropertyKey, any>, K extends keyof T>(
obj: T,
keys: K[] | readonly K[]
): Omit<T, K>;

Usage

typescript
import { omit } from '@modern-kit/utils';

omit({ a: 1, b: 2, c: 3, d: 4 }, ['a', 'd']); // { b: 2, c: 3 }