I am pretty stuck right now on this, how can I get a parent class constructor's parameter? I want to get the Lion's DNA, then pass it to the baby lion and use it. Note that this isn't really for my personal use but rather it's a package / module, so I can't enter what I've entered in my code.
Example code:
class Lion {
constructor(client, DNA = {}) {
this.sharp = howsharp;
this.client = client;
}
}
class BabyLion extends Lion {
constructor(client) {
super(client, How can I get DNA??);
}
}
Things I've tried:
super(client)andsuper(client, {somestuff})- Doesn't work obviously, because I am chaging the DNA of the Lion that has been declared beforehand.- Having an empty variable
let dnaand then doingdna = DNAand then exporting it - 'obviously' did not work.
super()you can either passDNAor not pass it. What would make sense (and be consistent with actual reality) would be for there to be a method onLionto make a newBabyLion. You have to have an instance ofLion, in other words.Lioninstance. You could also have one of the arguments to theBabyLionconstructor be the parentLioninstance.BabyLiondoesn't declare aDNAparameter, then no, it's not accessible. Whence would it come?DNA(with your implementation) this way: setDNAas class property inLionclass then access property in descendant class (BabyLion) aftersupercall