var a1 = Object(); var 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.co优艾设计网_设计客nstructor); console.log(b2.constructor);// 出错
由于b2没有使用new操作符,那么他的constructor == undefined。
从理论上讲,a1.constructor也没有定义,但其可以正常返回值,为什么?
与一切对象都继承自Object有关么?
纆g 2022-08-15 16:46 优艾设计网_在线设计
When called in a non-constructor context, Object behaves identically to new Object().
精彩评论