📦 Checks if a value is an object and not null.
Info
In JavaScript, typeof null is 'object', but this function correctly returns false for null.
Info
This function returns true for any value where typeof val === 'object', such as Arrays, Dates, Maps, Sets, etc.
Syntax
TypeScript
import { isObject } from '@opentf/std'; isObject(val: unknown): val is object
Parameters
val: The value to check.
Returns
true if the value is an object and not null, false otherwise.
Examples
TypeScript
isObject({}) //=> true isObject([]) //=> true isObject(new Date()) //=> true isObject(new Map()) //=> true isObject(null) //=> false isObject(123) //=> false