javascript - TypeError: Xjs("hi").getName is not a function showing in firebug console -
why code showing error in firebug?
var xjs =function(name){ if(!(this instanceof xjs)) return new xjs(name) }; xjs.prototype={ constructor:xjs, xjs:function(){this.name=name;}, getname:function(){ alert(this.name); } }
in firebug:
xjs('hi').getname();
var xjs =function(name){ if(!(this instanceof xjs)) return new xjs(name) this.name = name; }; xjs.prototype={ constructor:xjs, getname:function(){ alert(this.name); } } xjs('hi').getname();
you not need pass methods in prototype name
treat object. name
available this.name
members of object
Comments
Post a Comment