jQuery.isPlainObject() function is used to determine whether the specified parameter is a pure object.
The so-called "pure object" means that the object is created through "{}" or "new Object".
This function belongs to the global jQuery object.
Syntax
jQuery 1.4 Newly addedThe static function.
jQuery.isPlainObject( object )
Parameters
Parameters
Description
object Any type needs to be Arbitrary value to judge.
Note: Host objects (or other objects used by the browser host environment to complete the ECMAScript execution environment) are difficult to perform cross-platform feature detection. Therefore, $.isPlainObject() may give different results on different browsers for instances of these objects.
Return value
jQuery.isPlainObject()The return value of the function is of Boolean type. If the specified parameter is a pure object, it returns true, otherwise it returns false.
Example & Description
The jQuery sample code for the jQuery.isPlainObject() function is as follows:
//在当前页面内追加换行标签和指定的HTML内容 function w( html ){ document.body.innerHTML += "<br/>" + html; } w( $.isPlainObject( { } ) ); // true w( $.isPlainObject( new Object() ) ); // true w( $.isPlainObject( { name: "CodePlayer"} ) ); // true w( $.isPlainObject( { sayHi: function(){} } ) ); // true w( $.isPlainObject( "CodePlayer" ) ); // false w( $.isPlainObject( true ) ); // false w( $.isPlainObject( 12 ) ); // false w( $.isPlainObject( [ ] ) ); // false w( $.isPlainObject( function(){ } ) ); // false w( $.isPlainObject( document.location ) ); // false(在IE中返回true) function Person(){ this.name = "张三"; } w( $.isPlainObject( new Person() ) ); // false
The above is the detailed content of Detailed explanation of jQuery.isPlainObject() function usage. For more information, please follow other related articles on the PHP Chinese website!