I am wondering what's the difference between setting methods via Class body vs prototype binding in JS. (if any)
I am currently working on Eloquent JavaScript example and I was surprised when author firstly created a class with bunch of methods inside its body and then created another method with className.prototype.methodName = function(){}
class Cat {
constructor() {
}
method1() {
console.log("m1");
}
}
Cat.protoype.method2 = function() {
console.log("m2");
}
classis just newer syntax.