代理constructor,prototype且不让instanceof失效

function NewClasse(superclass){
    
return function classe(){
        
if (classe.prototype != superclass) {
            classe.prototype 
= superclass;
            
return new classe();
        } 
else {
            classe.constructor.apply(
this, arguments);
        }
    };
};
= {x:1}
= NewClasse(B);
= new A();
alert(a 
instanceof A);
alert(a.x);

转载于:https://www.cnblogs.com/hackwaly/archive/2008/08/01/1257783.html

你可能感兴趣的:(代理constructor,prototype且不让instanceof失效)