The alert works in the following code if I remove the class declaration. I feel it should work with or without it. What am I missing?
class MyClass {
constructor MyClass() {
let x = 0;
}
}
alert("hi");
>Solution :
You have to remove the name MyClass in the constructor.
You can refer to the official documentation
class MyClass {
constructor () {
let x = 0;
}
}
alert("hi");