JQuery | isPlainObject() Method
This isPlainObject() Method in jQuery is used to check to see if an object is a plain object.
Syntax:
jQuery.isPlainObject( obj )
Parameters: This method accept a single parameter that is mentioned above and described below:
- obj: This parameter holds the object that will be checked to see if it’s a plain object.
Return Value: It returns the boolean value.
Below examples illustrate the use of isPlainObject() method in jQuery:
Example 1: In this example, the isPlainObject() method checks an object to see if it’s a plain object.
<!DOCTYPE html>
< html >
< head >
< meta charset = "utf-8" >
< title >JQuery | isPlainObject() method</ title >
< script src =
</ script >
</ head >
< body style = "text-align:center;" >
< h1 style = "color: green" >
GeeksforGeeks
</ h1 >
< h3 >JQuery | isPlainObject() method</ h3 >
< b >Whether '{}' is a Plain Object : </ b >
< p ></ p >
< script >
$("p").append("" + $.isPlainObject({}));
</ script >
</ body >
</ html >
|
Output:
Example 2: In this example, the isPlainObject() method also checks an object to see if it’s a plain object.
<!DOCTYPE html>
< html >
< head >
< meta charset = "utf-8" >
< title >JQuery | isPlainObject() method</ title >
< script src =
</ script >
</ head >
< body style = "text-align:center;" >
< h1 style = "color: green" >
GeeksforGeeks
</ h1 >
< h3 >JQuery | isPlainObject() method</ h3 >
< p id = "geek1" >
Whether 'document.location' is a Plain Object:
</ p >
< p id = "geek2" >Whether String is a Plain Object:
</ p >
< script >
// Document.location
$("#geek1").append("" + $.isPlainObject(document.location));
// string = "Shubham_Singh"
$("#geek2").append("" + $.isPlainObject("Shubham_Singh"));
</ script >
</ body >
</ html >
|
Output:
Last Updated :
30 Apr, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...