Everything I have read seems to favor declaring methods of object constructor functions in a prototype declarations instead of putting the method straight into the initial constructor.
function MyClass(name){
this.name = name;
}
MyClass.prototype.callMethod = function(){
console.log(this.name);
};
Would this be recommended? If so what are the disadvantages to putting the method inside the initial constructor like so.
function MyClass(name){
this.name = name;
this.callMethod = function(){
console.log(this.name);
};
}
I'm assuming a case as simple as this that it doesn't really matter either way, but in cases of larger objects what are the implications in declaring the method in both stated cases?