what should be the good approach to write javascript code?
- by Bhupi
Hi,
which should be the good approach to write javascript code and why?
1)
var myClass = function(){}
myClass.prototype.init = function(x, y){
this.width = x;
this.height = y;
}
myClass.prototype.show = function(){
alert("width = "+ this.width+" height = "+ this.height);
}
2)
var myNewClass = {
init : function(x, y)
{
this.width = x;
this.height = y;
},
show : function()
{
alert("width = "+ this.width+" height = "+ this.height);
}
}