Function isNonNullObject

  • Determines whether a value is a non-null object, including arrays.

    This predicate accepts arrays, ordinary objects, class instances, boxed primitives, and specialized built-in objects such as Date, Map, and Set. It rejects null, primitive values, functions, and class constructors.

    Unlike isObject, this function accepts arrays. Unlike isObjectOrFunction, it rejects functions and class constructors.

    Known object types retain their existing static type. Mixed unions are narrowed to their non-null, non-callable object members.

    Type Parameters

    • T

    Parameters

    • value: T

      The value to evaluate.

    Returns value is Exclude<
        T & object,
        ((...args: any[]) => any)
        | (new (...args: any[]) => any),
    >

    Whether the value has a runtime type of object and is not null.

    const value: string[] | (() => void) | undefined = [];

    if (isNonNullObject(value))
    {
    value.push('entry');
    // `value` is narrowed to `string[]`.
    }