goldies
    Preparing search index...

    Function omit

    • Creates a copy of an object without the given properties: the opposite of pick.

      The copy is shallow, so nested objects are shared with the original, which isn't changed.

      Type Parameters

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

      Parameters

      • obj: T

        The object to copy.

      • keys: readonly K[]

        The properties to leave out.

      Returns Omit<T, K>

      The new object.

      const user = { id: 1, name: 'Ada', password: 'hunter2' };

      omit(user, ['password']); // { id: 1, name: 'Ada' }