I have a question about a behaviour I want to automate each time I extend a class resulting in a way to know how many classes separate the last iteration of inheritance with the very first class.
So basically the behaviour I want to replicate is this one.
class Zero {
static count = 0;
get count(){
return this.constructor.count;
}
}
class One1 extends Zero{
static count = super.count +1; //I would love to automate this line so I just have to call it once in the parent constructor or in this constructor so I only would have to call super in the child's constructor
}
class One2 extends Zero{
static count = super.count +1;
}
class Two extends One1{
static count = super.count +1;
}
let one1 = new One1();
let one2 = new One2();
let two = new Two();
one1.count // return 1
one2.count // return 1
two.count // return 2
Thank you in advance!