+ 1

Is constructor overloading possible

class Rectangle { constructor(height, width) { this.height = height; this.width = width; } get area() { return this.calcArea(); } calcArea() { return this.height * this.width; } } const square = new Rectangle(5, 5); console.log(square.area); // 25 Here if we add another constructor with only one attribute will it do constructor overloading like in c++

20th Aug 2020, 7:56 AM
Azimul Hasan
Azimul Hasan - avatar
1 Resposta
+ 3
Javascript doesn't support function or construct overloading.
20th Aug 2020, 8:04 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar