I'm from C++, and i try to understand JS OOP. But I have to admit it isn't simple ... I want to create a "simple" class.
Like this :
class Being {
Being(float A, float B) {...}
Being(string A, string B) {...}
Being() {...}
getInfo() {
console.log(...)
}
[...]
}
I know there is some ways to do it, like this :
class Being {
Being(A=null,B=null) {
if (A === null && B === null) {}
if (typeof A == String && typeof B == String) {}
if (!isNaN(A) && !isNaN(B)) {}
}
}
But i want to know if there is a most elegant way to do this. I kown there is also the function 'constructor' keyword, but it seems to doesn't work for multiples overloading.
Thx