@supuwoerc/toolkit
    Preparing search index...

    Function omit

    • 从对象中排除指定的属性 Omit specified properties from an object

      Type Parameters

      • O extends object

        原始对象的类型 / Type of the original object

      • K extends string | number | symbol

        要排除的属性键类型 / Type of keys to omit

      Parameters

      • obj: O

        原始对象 / The original object

      • keys: readonly K[]

        要排除的属性键数组 / Array of keys to omit

      • OptionalomitUndefined: boolean = false

        是否同时排除值为 undefined 的属性 / Whether to also omit properties with undefined value

      Returns Omit<O, K>

      排除指定属性后的新对象 / New object with specified properties omitted

      // 示例1: 基本用法 / Basic usage
      const obj = { a: 1, b: 2, c: 3 };
      omit(obj, ['b']); // { a: 1, c: 3 }
      // 示例2: 排除 undefined 值 / Omit undefined values
      const obj = { a: 1, b: undefined, c: 3 };
      omit(obj, ['c'], true); // { a: 1 }