var a1 = Object(); va优艾设计网_Photoshop百科r a2 = new Object(); console.log(a1); console.log(a1.constructor); console.log(a2.constructor);var Person = function(){ this.name = "张三" } var b1 = new Person(); var b2 = Person(); console.log(b1.constructor); console.log(b2.constructor);// 出错
由于b2没有使用new操作符,那么他的constructor == undefined。
从理论上讲,a1.constructor也没有定义,但其可以正常返回值,为什么?
与一切对象都继承自Object有关么?
无料丶 2022-06-02 18:34优艾设计网_设计
When called in a non-constructor context, Object behaves identically to new Object().
精彩评论