When i change a function draw(){ //}
to draw = () => { // }
I am getting an error like \"Uncaught SyntaxError: Unexpected token =\".
What may be
First of all, you probably shouldn't do that. Why? Well, because arrow functions are not semantically the same as regular functions.
If you register the functions as this.draw = () => {//}
, then every instance of your class
* will have a duplicate definition of that function which is a waste of space and a misuse of some core language features such as prototype inheritance.
draw()
on the other hand registers that function on the prototype
so that definition of the draw function can be shared between all instances and even changed dynamically for ALL instances at the same time.