function A() {
this.foo = function() {
return "bar";
};
}
A.prototype.foo = function() {
return "bar";
};
I mostly go by the second approach for adding "instance methods". Mostly because of habit and it's a little memory saver. But when is it appropriate to use the first approach?
NOTE: This question has almost been asked before but they mostly talk about the different and this question is more when to use each.