Class Inheritance
JavaScript
class Foo {
constructor(who) {
this.me = who;
}
// this method goes into prototype of Foo
identify() {
return " I am :" + this.me;
}
// this method is avilable on class Foo directlly
static hello() {
return " Hello from static !!";
}
}
class Bar extends Foo {
constructor(who) {
super(who);
this.calledFrom = "Bar";
}
identify() {
return super.identify();
}
speak() {
return " Hello all !"+this.identify();
}
}
var b1 = new Bar("b1");