主题
isPlainObject
js
_.isPlainObject(value)检查 value 是否是普通对象,即由 Object 构造函数创建的对象或具有 [[Prototype]] 或 null 的对象。
¥Checks if value is a plain object, that is, an object created by the Object constructor or one with a [[Prototype]] of null.
新增于
¥Since
0.8.0
参数
¥Arguments
value(*):要检查的值。¥
value()*: The value to check.
返回
¥Returns
(布尔):如果 value 是普通对象,则返回 true,否则返回 false。
¥(boolean): Returns true if value is a plain object, else false.
示例
¥Example
js
function Foo() {
this.a = 1;
}
_.isPlainObject(new Foo);
// => false
_.isPlainObject([1, 2, 3]);
// => false
_.isPlainObject({ 'x': 0, 'y': 0 });
// => true
_.isPlainObject(Object.create(null));
// => true