I'm trying to create an ES6 class with two constructors. The code looks something like this:
class MyClass {
constructor(a, b) {
this.a = a;
this.b = b;
}
constructor(c) {
this.a = c;
this.b = c;
}
}
But I'm getting this syntax error:
Uncaught SyntaxError: A class may only have one constructor
.
Is there any workaround that would let me have multiple constructors or am I just limited to one constructor in JS?