Types
isObject

📦 Checks if a value is an object and not null.

In JavaScript, typeof null is 'object', but this function correctly returns false for null.

This function returns true for any value where typeof val === 'object', such as Arrays, Dates, Maps, Sets, etc.

Syntax

import { isObject } from '@opentf/std';
 
isObject(val: unknown): boolean

Parameters

  • val: The value to check.

Returns

true if the value is an object and not null, false otherwise.

Examples

isObject({}) //=> true
 
isObject([]) //=> true
 
isObject(new Date()) //=> true
 
isObject(new Map()) //=> true
 
isObject(null) //=> false
 
isObject(123) //=> false

Related

Try