87,901
社区成员
发帖
与我相关
我的任务
分享
obj={
a :[],
b :{},
c : function(){
……
},
d : function(){
obj.a.push('3');
obj.c();
}
};
function test() {
alert(this);
}
alert(this); // window
new test();// Object(代表new出来的object)
test(); // window
function Father(name) {
this.name = name;
}
function Child(name) {
this.Father = Father;
// Father的this挂靠到Child上,形成对象冒充(也就是说,Father中的this,就是现在看到的this)
this.Father(name);
delete(this.Father);
}
alert(new Child("123").name);
function Test(name) {
this.name = name;
}
Test.prototype = {
sayHello: function() {
alert(this.name);
}
};
obj={
me:this,
a :[],
b :{},
c : function(){
……
},
d : function(){
this.a.push('3');
this.c();
}
};
obj={
a :[],
b :{},
c : function(){
……
},
d : function(){
this.a.push('3');
this.c();
}
};