You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * @param {any} obj The object to inspect. * @returns {boolean} True if the argument appears to be a plain object. */exportdefaultfunctionisPlainObject(obj){if(typeofobj!=='object'||obj===null)returnfalseletproto=objwhile(Object.getPrototypeOf(proto)!==null){proto=Object.getPrototypeOf(proto)}returnObject.getPrototypeOf(obj)===proto}
函数源代码
函数用途
用于判断是否是纯粹的对象,即是由字面量
{}
,或者new Object()
生成的对象 。代码解读
总结
与其他普通对象不同的是,纯粹对象的原型链上只有一个原型,就是
Object.prototype
,函数就由此进行判断。如果你是一个普通对象,如 :而
The text was updated successfully, but these errors were encountered: