Hello.
I am trying to figure out how JS's inheritance chain works.
Lets say I have a "parent" class, and a "bigBro" class, and a "LilBro" class.
By using the extend keyword I create a inheritance chain, (I dont know the correct word for it.)
class Parent{
parentArr = [];
constructor(arr){
//This assigns and creates properties
parentArr = this.initializeArr()
}
thisIsParentsMethod(){
}
// ... Rest of Code here
}
class BigBro extends Parent{
constructor(arr){
super(arr)
}
thisIsBigBrosMethod(){
}
// ... Code here
}
class LilBro extends BigBro{
constructor(arr){
super(arr)
}
doSomething(){
super.thisIsParentsMethod() // If I use super it says a property is not defined
this.thisIsParentsMethod() // This returns undefined method thisIsParentsMethod
}
}
From the LilBro class I expect to be able to use all methods of BigBro and Parent, how ever it does not seem to work correctly, if I use super before a call, it errors out with property is not defined.
If I use this it returns undefined method.
My question is, is it possible to inherit like this?
What would the alternative be?