javascript继承--对象冒充
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();
                    
                
                
            
        
浙公网安备 33010602011771号