Function isPlainObject

  • Checks if a given value is a plain JavaScript object.

    Remarks

    A plain object is defined as an object whose prototype is either null or Object.prototype.

    Example

    isPlainObject({})
    // => true

    isPlainObject({ a: 1 })
    // => true

    isPlainObject(new Object())
    // => true

    isPlainObject(Object.create(null))
    // => true

    isPlainObject(undefined)
    // => false

    isPlainObject(null)
    // => false

    isPlainObject(1)
    // => false

    isPlainObject('a')
    // => false

    isPlainObject(false)
    // => false

    isPlainObject([])
    // => false

    isPlainObject(() => {})
    // => false

    Type Parameters

    • T extends object = object

      The expected type of the input value.

    Parameters

    • value: unknown

      The value to be checked.

    Returns value is T

    true if the value is a plain JavaScript object, false otherwise.

Generated using TypeDoc v0.24.7