Is constructor overloading possible | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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