isPlainObject: function(
obj ) {
//不是object或者是DOM元素或是window返回false
if (
jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow(
obj ) ) {
return false ;
}
// Support: Firefox <20
// The try/catch suppresses exceptions
thrown when attempting to access
// the "constructor" property of certain
host objects, ie. |window.location|
// https://bugzilla.mozilla.org/show_bug.cgi?id=814622
try {
//是自定义对象返回false
//判断自定义对象的依据是如果isPrototypeOf方法是从{}的原型对象中继承来的那么便是自定义对象
if (
obj.constructor &&
!hasOwn.call( obj.constructor.prototype, "isPrototypeOf" )
) {
return false ;
}
} catch (
e ) {
return false ;
}
// If the function hasn‘t returned
already, we‘re confident that
// |obj |
is a plain object, created by {} or constructed with new Object
return true ;
},