Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extend = function(Child, Parent)
- {
- var F = function() { };
- F.prototype = Parent.prototype;
- Child.prototype = new F();
- Child.prototype.constructor = Child;
- Child.super = Parent.prototype;
- };
- >function (Child, Parent)
- > {
- > var F = function() { };
- > F.prototype = Parent.prototype;
- > Child.prototype = new F();
- > Child.prototype.constructor = Child;
- > Child.super = Parent.prototype;
- > }
- function A() { }
- >undefined
- A.prototype.init = function(){this.name = 'A'}
- >function (){this.name = 'A'}
- function B(){ }
- >undefined
- extend(B, A)
- >undefined
- count = 0;
- >0
- B.prototype.init = function(){ if (++count < 100) console.log('B.prototype.init.apply', this); this.constructor.super.init.apply(this,arguments); this.extra = 'im B';}
- >function (){ if (++b < 100) console.log('B.prototype.init.apply', this); this.constructor.super.init.apply(this,arguments); this.extra = 'im B';}
- function C() { }
- >undefined
- extend(C, B)
- >undefined
- C.prototype.init = function(){ if (++count < 100) console.log('C.prototype.init.apply', this); this.constructor.super.init.apply(this,arguments); this.extraC = 'mimimi';}
- >function (){ if (++count < 100) console.log('C.prototype.init.apply', this); this.constructor.super.init.apply(this,arguments); this.extraC = 'mimimi';}
- (new C).init()
- >C.prototype.init.apply
- >C
- >B.prototype.init.apply
- >C
- >B.prototype.init.apply
- >C
- >B.prototype.init.apply
- >C
- >B.prototype.init.apply
- >C
- >B.prototype.init.apply
- >C
- >B.prototype.init.apply
- >C
- >B.prototype.init.apply
- >C
- >B.prototype.init.apply
- >C
- ...
- >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