Search Docs
isPlainObject
检查给定的 value 是否为普通对象,即是否由 Object 构造函数创建或是否为 {} 字面量形式创建。
value
Object
{}
import { isPlainObject } from 'funtool'; isPlainObject({}); // ✅ true isPlainObject(new Object()); // ✅ true isPlainObject(Object.create(null)); // ✅ true isPlainObject([]); // ❌ false isPlainObject(new Date()); // ❌ false isPlainObject(() => {}); // ❌ false isPlainObject(null); // ❌ false
function isPlainObject(v: any): boolean
v
any
boolean
true
false