Skip to main content

isObject

Callable

  • isObject<T>(value: unknown): value is T

  • Returns true if the value is an object.

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

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

    Generics can be used to type the return value of the object (when necessary).

    interface Person {
    name: string;
    }

    if (isObject<Person>(person)) {
    console.log(person.name);
    }

    Type parameters

    • T = object