Imagine I have 3 classes Child
, Parent
and Grandparent
connected in hierarchy as follows:
class Grandparent {
set myField(value) {
console.log('Grandparent setter');
}
}
class Parent extends Grandparent {
set myField(value) {
console.log('Parent setter');
}
}
class Child extends Parent {
set myField(value) {
//I know how to call Parent's setter of myField:
//super.myField = value;
//But how to call Grandparent's setter of myField here?
}
}
How can I call Grandparent
's setter of myField
in setter of Child
class?
I'm interested particularly in setter, not a method. Also it's much preferable to not make changes in Parent
of Grandparent
classes.
I don't see how that is possible using super
because it references just Parent
class, as well as using something like Grandparent.prototype.<what?>.call(this, ...)
because I don't know what exactly to call in the prototype.
Does anyone have any suggestions for this case?
Thanks in advance!