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

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -