Given two classes where I want to give the methods of one to another:
class a {}
class b {say() {console.log('hello')}}
var foo = new a();
How come this works:
a.prototype.say = b.prototype.say;
foo.say(); //'hello'
But this doesn't?
a.prototype = b.prototype;
foo.say(); //foo.say is not a function
To be clear, I'm not asking how to give one class's methods to another, but why prototype behaves like this.
Bonus question: what's the difference between defining a method inside a class block and defining it by directly assigning it to the prototype?