Possible Duplicate:
Use of 'prototype' vs. 'this' in Javascript?
I am confused with these two type of adding a method to a function. Let me explain with an example.
var foo = function(){
this.bar = function(){alert('I am a method')}
}
foo.prototype.baz = function(){alert('I am another method')}
var car = new foo();
Now at this point we can use baz and bar methods for car. Well, but what is the difference between them. What is the nuance adding a method to function's prototype or it's constructor.
Thanks..