isPlainObject

Check whether a value is a plain object created by an object literal or Object, excluding arrays, dates, functions, and class instances.

Usage

Check whether a value is a "plain" object (created by {} or new Object()), excluding arrays, null, and other non-plain-object types such as new Date(). This is a TypeScript type guard function.

import { isPlainObject } from '@movk/core'

isPlainObject({}) // => true
isPlainObject(new Object()) // => true
isPlainObject(new Date()) // => false
isPlainObject([]) // => false

API

isPlainObject(value: unknown): value is Record<string, any>

Parameters

value
unknown required
The value to check.

Returns

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

Changelog

No recent changes
Copyright © 2024 - 2026 YiXuan - MIT License