Why the second pattern is used more then the 1st when both of them do the same? Or I'm wrong?
function Foo1(){
this.name = "Foo 1";
this.hello = function(){
console.log("hello", this.name);
};
}
var test1 = new Foo1();
test1.hello();
function Foo2(){
this.name = "Foo 2";
}
Foo2.prototype.hello = function(){
console.log("hello", this.name);
};
var test2 = new Foo2();
test2.hello();