1, if the parameter is an object, core js object (native ECMAScript object) or host object (host object), then the object will be returned directly. The object constructor it generates is still the constructor of the passed parameter object. The consequence of this is that although the object is new Object, its constructor is not necessarily Object.
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 basic type object, such as a string (String), a number (Number), a Boolean value (Boolean), which is packaged into an object (converted into its corresponding packaging class) and returned .
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 can be seen from the above, when When passing parameters, the constructor of the object generated using new Object does not necessarily point to Object. It will point to Object only by chance, such as
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 can explain why the following code in jquery1.4 returns false
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