Skip to content

omit

omit<T, K>(obj, keys): Simplify<Except<T, K, { requireExactProps: true; }>>

It takes an object and an array of keys, and returns a new object with those keys excluded.

Example

omit({foo: "bar", bar: "foo"}, ["foo"])
// => {bar: "foo"}
omit({foo: "bar", bar: "foo"}, [])
// => {foo: "bar", bar: "foo"}

Alternatives

Type Parameters

T extends object | ArrayLike<unknown>

K extends string | number | symbol

Parameters

obj

T

The object to take the properties from.

keys

readonly K[]

The keys to omit on the object.

Returns

Simplify<Except<T, K, { requireExactProps: true; }>>

The constructed object.