✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
class AbstractShape {constructor() {
if (new.target === AbstractShape) {
throw new Error('Cannot instantiate abstract class');
}
}
area() {
throw new Error('Method area() must be implemented');
}
}
class Rectangle extends AbstractShape {
constructor(w, h) {
super();
this.w = w; this.h = h;
}
area() { return this.w \* this.h; }
}
const r = new Rectangle(4, 5);
console.log(r.area());