function Parent(name){
this.name=name;
this.sayHello=function(){
alert(this.name);
}
}
function child(name,hobby){
this.method=Parent;
/*
调用Parent()函数,添加了name,sayHello属性
*/
this.method(name);
delete this.method;
}
var ch=new child("小张","打酱油");
ch.sayHello();
转载于:https://www.cnblogs.com/unbreakable/archive/2012/04/08/2437826.html