js新手,求助function a(){
this.b=100;
this.c={
d:function(){
alert(this.b);//这里会弹出undefined,怎么才能显示function a()中的100?
}
}
}
var i=new a()
i.c.d()
this.b=100;
this.c={
d:function(){
alert(this.b);//这里会弹出undefined,怎么才能显示function a()中的100?
}
}
}
var i=new a()
i.c.d()
var me = this;
this.b=100;
this.c={
d:function(){
alert(me.b);//这里会弹出undefined,怎么才能显示function a()中的100?
}
}
}
var i=new a()
i.c.d()
所以把this指代提出来 就可以了