Accessing child properties when calling a function from its parent

So I've a Shape parent class and a Circle child class. The child class calls the parent's constructor with super, which then callsgenerateMarkup - a function all children have. Problem is this function uses an instance variable in the child class, and this appear not to have been set yet. Not sure if I've made a mistake, but I had thought (admittedly from hazy Java memories) that instance variables were set prior to constructors running? Codepen demo: https://codepen.io/nwoodward/pen/rNrNdYQ?editors=0011 Appreciate any help!
nick
CodePen
rNrNdYQ
...
1 Reply
JWode
JWodeOP•2y ago
In case anyone is interested, I think simply moving the call to generateMarkup into each child constructor is the easiest fix 🙂
Want results from more Discord servers?
Add your server