function extend(Father,Son){
var F=function(){};
F.prototype=Father.prototype;
Son.prototype=new F();
Son.prototype.constructor=Son;
Son.uber=Father.prototype;
}
function Grandfather(){}
Grandfather.prototype.toString=function(){
alert(this)
};
function Father(){};
extend(Grandfather,Father);
function Son(){};
extend(Father,Son);
var p=new Son();
p.toString();
这段代码会报错Uncaught RangeError: Maximum call stack size exceeded;
可我将Grandfather.prototype.toString的alert改为console.log就可以正常运行了,
后来我把toString改下名又可以正常alert出 了,
这是为什么
qq_冲哥_0
相关分类