Javascript inherance and use of super: is this possible?

Posted by Totty on Stack Overflow See other posts from Stack Overflow or by Totty
Published on 2010-12-25T06:32:06Z Indexed on 2010/12/25 6:54 UTC
Read the original article Hit count: 215

Filed under:
|
var Parent = function(value){
   this.value = value;
   this.value1 = 3;
   this.hello = function(text){
     alert(this.value1 + text);
   }
}

var Child = extends(Parent, function(value){
   this.value1 = 1;
   this.hello = function(text){
     this.super.hello(text);
     alert('Child' + this.value1 + this.value);
   }
})

var child = new Child(2);
child.hello('ola');
// this must output 2 alerts:
// 1: "1ola"
// 2: "Child1ola"

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about inheritance