isPlainObject

检查一个值是否为“纯”对象(由 {} 或 new Object() 创建)。

用法

检查一个值是否为“纯”对象(由 {}new Object() 创建),排除数组、null、以及其他非对象类型(如 new Date())。这是一个 TypeScript 类型保护函数。

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>

参数

value
unknown required
需要检查的值。

返回值

boolean
如果值为纯对象,则返回 true,否则返回 false

Changelog

b6146 — refactor: 统一源码文件命名为 camelCase

Copyright © 2024 - 2026 YiXuan - MIT License