jty
    Preparing search index...

    Function hasOwnProp

    • Same as hasProp but checks for own properties (not inherited properties)

      Type Parameters

      • K extends PropertyKey

      Parameters

      • x: unknown

        an object

      • ...propNames: readonly K[]

        one or more property names

      Returns x is Record<K, unknown>

      hasOwnProp({ foo: 'bar' }, 'foo') => true
      hasOwnProp({ foo: 'bar' }, 'baz') => false
      hasOwnProp({ foo: 'bar', baz: 'cux' }, 'foo', 'baz') => true

      // Unlike hasProp, it does not find inherited properties
      hasOwnProp({}, '__proto__') => false
      hasOwnProp({}, 'constructor') => false