So I'm curious if it's possible from a base (parent) class to access static properties from all levels in a class hierarchy.
Let's paint an example:
class Tier1 {
static NUMBERS = ['one', 'two'];
getNumbers() {
// how to do here?
return this.constructor.NUMBERS.join(', ');
}
}
class Tier2 extends Tier1 {
static NUMBERS = ['three'];
}
class Tier3 extends Tier2 {
static NUMBERS = ['four', 'five'];
}
class Tier4 extends Tier3 {
static NUMBERS = ['six'];
}
const t1 = new Tier1(); t1.getNumbers(); // Expect to get "one, two"
const t2 = new Tier2(); t2.getNumbers(); // Expect to get "one, two, three"
const t3 = new Tier3(); t3.getNumbers(); // Expect to get "one, two, three, four, five"
const t4 = new Tier4(); t4.getNumbers(); // Expect to get "one, two, three, four, five, six"
Is it possible to achieve this effect? Can I traverse down the class instance hierarchy from this in a dynamic way?
Would love some input and ideas here