There are several ways to implement OOP and inheritance.
I checked a lot and choose below one which is simple to program and easy to understand.
<script>
//prototype Chain to implement mutilple extends
function ClassA() {
this.name = "A";
this.displayA = function(p){return p;}
}
ClassA.prototype.testA = function(p){return p;}
function ClassB(){
this.name = "B";
this.displayB = function(p){return p;}
}
ClassB.prototype = new ClassA();
ClassB.constructor = ClassB;
ClassB.prototype.testB = function(p){}
function ClassC(){
}
ClassC.prototype = new ClassB();
ClassC.constructor = ClassC;
var clazzc = new ClassC();
console.log(clazzc.displayB("ClassB"));
console.log(clazzc.displayA("ClassA"));
console.log(clazzc.testA("ClassC"));
</script>
Console outputs:
Notes:
1. Properties and functions encapsulated inside the Object will be allocated for each instance;
2. Properties and functions which are created by prototype form, like function testA & testB, can only be used by the Object own instance, means it's SubObject instance cannot use util SubObject extends parent's prototype.
3. Array properties defined by prototype will be shared by all instance, so should be noticed that every push or pop activity did by one instance will impact others.