You can’t use variables (let
, var
, const
) within classes like that.
You need to write a constructor
and within the constructor
, you can define what attributes the class should have, e. g. color
.
For methods, you simply write the methods name (without function
or the ES6 syntax).
class A {
constructor() {
this.color = "red";
}
handleClick() {}
handleLongClick() {}
};
console.log('done');
solved whats wrong with the below code?