Skip to main content

isPlainObject

Callable

  • isPlainObject<T>(value: unknown, loose?: boolean): value is T

  • Like isObject but only returns true if the value is a plain object (no class instances, built-ins, etc). It achieves this by comparing the value's prototype to the built-in Object types. If you need to run these checks for cross-realm objects, pass true to the loose argument.

    import { isPlainObject } from '@boost/common';

    isPlainObject({}); // true
    isPlainObject(new Foo()); // false
    isPlainObject([]); // false

    Type parameters

    • T = object