1, the parameter is an object, a core JS object (native ECMAScript object) or a host object (host objects), then the object is returned directly.
The object builder it generates is still the constructor of the passed Parameter object. The result is that although the object is new, its constructor is not necessarily object.
Copy Code code 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, the parameter is a base type object, such as a string, a number, a Boolean value (Boolean), which is wrapped as an object (converted to its corresponding wrapper class) and returned.
Copy Code code 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
As you can see from the above, when you pass a parameter, the object that you build with the new object doesn't necessarily point to object, and only when it's funny, it points to object, like
Copy Code code 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 Code code 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