Suppose in JavaScript, I have a class Human and another class Child(Please dont kill me for using the word class)
function Human(name){
this.name=name;
}
function Child(age){
this.age=age;
}
I can create an object of Human as:
var h=new Human('MyName')
and an object of child as:
var c=new Child(10)
I can also do inheritance by:
var ih=Object.create(h)
to inherit/copy the created object h.
But, is there any way I can create an object of Child
and let it inherit the Human
class as well. i.e, my object should have both Human
and Child
attributes. And as far as Javascript is concerned, I believe it sounds like multiple inheritance. Is there a way to achieve this?