1. A parameter is an object. The core js object (native ECMAScript object) or host object will be returned directly.
The object constructor generated by the constructor is still the constructor of the passed parameter object. The consequence is that although the Object is a new Object, its constructor is not necessarily an Object.
Copy codeThe Code is as follows:
Function Person () {this. name = 'jack ';}
Var w = new Object (window ),
D = new Object (document ),
P = new Object (new Person ());
Console. log (w. constructor); //-> Window
Console. log (d. constructor); //-> HTMLDocument
Console. log (p. constructor); //-> Person
2. A parameter is a basic type object, such as a String, Number, or Boolean, which is encapsulated into an object (converted to its corresponding packaging class).
Copy codeThe Code is as follows:
Var s = new Object ('hello '),
N = new Object (22 ),
B = new Object (true );
Console. log (typeof s); //-> Object
Console. log (typeof n); //-> Object
Console. log (typeof B); //-> Object
Console. log (s. constructor); //-> String
Console. log (n. constructor); //-> Number
Console. log (B. constructor); //-> Boolean
It can be seen from the above that when passing a parameter, the Object generated using the new Object's constructor does not necessarily point to the Object, and will point to the Object only when it is very clever, such
Copy codeThe Code is as follows:
Var obj1 = new Object,
Obj2 = {};
Var o1 = new Object (obj1 );
O2 = new Object (obj2 );
Console. log (o1.constructor); //-> Object
Console. log (o2.constructor); //-> Object
The above shows why the following code in jquery1.4 + returns false.
Copy codeThe Code is as follows:
Function Person () {this. name = 'jack ';}
Var p = new Person ();
$. IsPlainObject (new Object (4); //-> false
$. IsPlainObject (new Object ('hello'); //-> false
$. IsPlainObject (new Object (true); //-> false
$. IsPlainObject (new Object (p); //-> false