uft
    Preparing search index...

    Function isPlainArray

    • Checks if a value passes Array.isArray and has prototype Array.prototype.

      Parameters

      • value: unknown

        The value to check.

      Returns value is unknown[]

      true if the check passes, false otherwise.

      This is useful for checking that the prototype of an array has not been modified. However, this will return false for arrays created in other realms since they will have a different prototype.

      isPlainArray([]) // true
      isPlainArray(new Array()) // true

      isPlainArray(new Uint16Array()) // false
      isPlainArray(Object.create(Array.prototype)) // false
      isPlainArray(Object.create(null)) // false
      isPlainArray(null) // false

      Comparison with Array.isArray:

      class MyArray extends Array {}
      Array.isArray(new MyArray()) // true
      isPlainArray(new MyArray()) // false