function Obj1(name){
this.__proto__={
Name:name,
getName:function(){
alert(this.Name);
}
};
}
function Obj2(name){
this.prototype={
Name:name,
getName:function(){
alert(this.Name);
};
};
}
x=new Obj1("blue shark");
z=new Obj2("red shark");
x.getName();
z.getName();// error:z.getName() is not a function
What is the difference between the two?Some say prototype
is used for constructor functions only but in this case it doesn't work.... instead the __proto__
work why?