Let\'s say I have this code:
(function(global) {
function Bar(foo) {
this.foo = foo;
return this;
}
Bar.prototype.getFoo = funct
If you have more than one instance of the "class" (using the term loosely), they all share the same prototype. So attaching things there is more light-weight, and it guarantees that they all have the same version (if that is what you want).
Think about it as instance fields vs class fields.
Prototypes can also be chained to allow for "inheritance" of fields.