isObject

Commons
stable

Type guard that returns true when the value is a plain (non-null, non-array) object. Excludes null and arrays which typeof incorrectly reports as "object".

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

obj
required
any
The value to test. null returns false even though typeof null === "object". Arrays also return false.

API

Return value

The value returned by this util.

true and narrows the type to object when the value is a non-null, non-array object; false otherwise.

Usage

Examples

Ready-to-paste usage snippets.

Distinguishing plain objects from other types

typescript