@bnidev/js-utils
    Preparing search index...

    Function omit

    • Creates a shallow copy of an object without the specified keys.

      Type Parameters

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

      Parameters

      • obj: T

        The source object to copy from.

      • keys: K[]

        An array of keys to omit from the copied object.

      Returns Omit<T, K>

      A new object with the specified keys omitted.

      This utility is useful for creating a new object that excludes certain properties, such as when you want to remove sensitive information or unnecessary data before sending it over a network or storing it. It can help maintain immutability by not modifying the original object.

      // ES Module
      import { omit } from '@bnidev/js-utils'

      // CommonJS
      const { omit } = require('@bnidev/js-utils')
      // Original object
      const user = {
      id: 1,
      name: 'John Doe',
      email: 'johndoe@example.com'
      }

      // Omit the 'email' property
      const userWithoutEmail = omit(user, ['email'])