Hey folks, here’s my solution: https://jsfiddle.net/Rynout/34yw9kje/
Any feedback would be much appreciated.
My question: in the source code of the finished example, there are two lines that I don’t see the point of:
Ball.prototype = Object.create(Shape.prototype); Ball.prototype.constructor = Ball;
(And the same two lines for the EvilCircle prototype…)
I understand that this first line actually establishes the inheritence, and the second line resets the constructor property. This ensures that the methods which belong to the prototype Shape can also be called by object instances of Ball/EvilCircle. But in this case, there are no methods defined on the prototype of Shape? So what is the point? The code seems to work fines when I remove these lines.
Or is this something that a developer should just get into the habit of doing, everytime a constructor which calls another constructor is created?
Thanks a ton!