Types
isPlainObject

📦 Checks if a value is a plain object.

A plain object is an object created by the {} object literal or one created with Object.create(null).

Syntax

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

Parameters

  • val: The value to check.

Returns

true if the value is a plain object, false otherwise.

Examples

isPlainObject({}) //=> true
 
isPlainObject({ a: 1 }) //=> true
 
isPlainObject(Object.create(null)) //=> true
 
isPlainObject(new Object()) //=> true
 
// Non-plain objects
isPlainObject([]) //=> false
 
isPlainObject(new Map()) //=> false
 
isPlainObject(new Error()) //=> false
 
isPlainObject(null) //=> false

Related

Try