jty
    Preparing search index...

    Function hasProp

    • Checks if x is a non-null object that has all the provided 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>

      const a = { b: undefined, c:[0, 1, 2]}
      hasProp(a, 'b') => true
      hasProp(a, 'b', 'c') => true // both `a.b` and `a.c` properties exist
      hasProp(a.c, '0', 1, 'length') => true // `a.c` is an array that has all those properties