• Category

    Create a copy of a provided object with the provided keys omitted. This is an implementation of the Omit<T, K> type in TypeScript.

    Time complexity: O(n)

    Space complexity: O(n)

    Type Parameters

    • T extends object
    • K extends string | number | symbol

    Parameters

    • object: T

      The object you are renaming a key of

    • keys: readonly K[]

      The keys to remove from the object

    Returns Omit<T, K>

    A new object containing the entries that were not omitted

    Object

    const object = { a: 1, b: 2, c: 3 };

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