Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- count = 0;
- extend = function(Child, Parent)
- {
- var F = function() { };
- F.prototype = Parent.prototype;
- Child.prototype = new F();
- Child.prototype.constructor = Child;
- Child.super = Parent.prototype;
- };
- function A() { }
- A.prototype.init = function(){ if (++count < 100) console.log('A.prototype.init.apply', this); this.name = 'A'}
- function B(){ }
- extend(B, A)
- B.prototype.init = function(){ if (++count < 100) console.log('B.prototype.init.apply', this); if (arguments.callee === this.constructor.super.init) { this.constructor.super.constructor.super.init.apply(this,arguments); } else { this.constructor.super.init.apply(this,arguments); } this.extra = 'im B';}
- function C() { }
- extend(C, B)
- C.prototype.init = function(){ if (++count < 100) console.log('C.prototype.init.apply', this); if (arguments.callee === this.constructor.super.init) { this.constructor.super.constructor.super.init.apply(this,arguments); } else { this.constructor.super.init.apply(this,arguments); } this.extraC = 'mimimi';}
- c= new C
- >C
- function D() { }
- >undefined
- extend(D,C)
- >undefined
- D.prototype.init = function(){ if (++count < 100) console.log('D.prototype.init.apply', this); if (arguments.callee === this.constructor.super.init) { this.constructor.super.constructor.super.init.apply(this,arguments); } else { this.constructor.super.init.apply(this,arguments); } }
- >function (){ if (++count < 100) console.log('D.prototype.init.apply', this); if (arguments.callee === this.constructor.super.init) { this.constructor.super.constructor.super.init.apply(this,arguments); } else { this.constructor.super.init.apply(this,arguments); } }
- d = new D
- >D
- d.init()
- >D.prototype.init.apply
- >D
- >C.prototype.init.apply
- >D
- >B.prototype.init.apply
- >D
- >C.prototype.init.apply
- >D
- >B.prototype.init.apply
- >D
- >C.prototype.init.apply
- >D
- >B.prototype.init.apply
- >D
- >C.prototype.init.apply
- >D
- >B.prototype.init.apply
- >D
- >C.prototype.init.apply
- >D
- >B.prototype.init.apply
- >D
- >C.prototype.init.apply
- >D
- >B.prototype.init.apply
- >D
- >C.prototype.init.apply
- >D
- >B.prototype.init.apply
- >D
- >C.prototype.init.apply
- >D
- >B.prototype.init.apply
- >D
- >RangeError: Maximum call stack size exceeded
- > arguments: Array[0]
- > get message: function getter() { [native code] }
- > set message: function setter() { [native code] }
- > stack: undefined
- > type: "stack_overflow"
- > __proto__: Error
Advertisement
Add Comment
Please, Sign In to add comment