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

    Function removeObjectKeys

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

      Type Parameters

      • T extends Record<string, unknown>

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

      • K extends string | number | symbol

        The keys of the object to be removed.

      Parameters

      • object: T

        The object from which keys will be removed.

      • keys: K[]

        The array of keys to remove from the object.

      Returns Omit<T, K>

      A new object with the specified keys removed.

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

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