I am trying to understand what is the difference when we write:
var Foo = function (){
 this.name = 'abc';
 this.alertName1 = function(){
  alert(this.name);
 }
}
Foo.prototype.alertName2 = function(){
  alert(this.name);
 }
Both methods will be available and are correct but when to use what is the question?
 
     
    