TS-Scribe - v0.6.2
    Preparing search index...

    Function omitObjectKeys

    • Creates a new object by excluding specified keys from the original object. This function avoids mutating the original object by creating a new object.

      Type Parameters

      • T extends object

        The type of the object from which keys will be omitted.

      • K extends string | number | symbol

        The keys of the object to be omitted.

      Parameters

      • object: T

        The object from which keys will be omitted.

      • keys: K[]

        The array of keys to omit from the object.

      Returns Omit<T, K>

      A new object with the specified keys excluded.

      const original = { a: 1, b: 2, c: 3 };
      const result = omitObjectKeys(original, ['b']);
      console.log(result); // { a: 1, c: 3 }

      const user = { name: 'Alice', age: 25, country: 'USA' };
      const publicData = omitObjectKeys(user, ['age']);
      console.log(publicData); // { name: 'Alice', country: 'USA' }