Skip to content

isPlainObject

检查值是否为纯对象(由 {}new Object() 创建)。

用法

js
import { isPlainObject } from 'js-cool'

签名

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

参数

参数类型描述
valueany要检查的值

返回值

boolean - 如果值是纯对象则返回 true

示例

js
isPlainObject({}) // true
isPlainObject({ a: 1 }) // true
isPlainObject(new Date()) // false
isPlainObject([]) // false
isPlainObject(null) // false

基于 MIT 许可发布