console.log("测试啦"); var a0 = new a(); function a(){ this.num = 5; } a.prototype.color = "red"; a.prototype = { name : "coyote", age : "不告诉你" } a.prototype.tes = "执行上下文"; var a1 = new a(); console.log(a0.color,a1.color); console.log(a0.name,a1.name); console.log(a0.num,a1.num); console.log(a0.tes,a1.tes); console.log(a1.__proto__ === a.prototype); console.log(a0.__proto__ === a.prototype);
求助,帮忙解释一下执行结果,或者是有兴趣的园友共同讨论。测试
在此,我附上执行结果:this
测试啦
red undefined
undefined "coyote"
5 5
undefined "执行上下文"spa
trueprototype
falsecode
我屡次尝试,因为文字太少,不能发送到首页和候选区,也不知诸位大神和各位园友何时能看到,不过在您看到这篇文章的时候,无论我是否已经解决问题,都欢迎各位发表评论,我们共同讨论。blog