Javascript – Why is super() calling the wrong constructor when using Object.setPrototypeOf?
I have the following code: class Polygon { constructor() { this.name = "Polygon"; } } class Rectangle { constructor() { this.name = "Rectangle"; } } class Square extends Polygon { constructor() { super(); } } Object.setPrototypeOf(Square, Rectangle); const instance =…