日期:2014-05-16 浏览次数:20397 次
//对象冒充
function FuncA(){
this.name = 'A';
}
function FuncB(){
this.method = FuncA;
this.method();//不就等同于FuncA()么;
delete this.method;
}
var a = new FuncA();
var b = new FuncB();
/*
alert(typeof a);
alert(typeof b);
alert(typeof FuncA);
alert(typeof FuncB);
*/
alert(b.name);
//对象冒充
function FuncA(){
this.name = 'A';
this.age=30;
}
function FuncB(){
this.method = FuncA;
this.method();//不就等同于FuncA()么;
delete this.method;
this.color ="red";
}
var a = new FuncA();
var b = new FuncB();
console.log(a.name);
console.log(b.name);
console.log(a.color);
console.log(b.color);