javascript access class method without initializing object -
i have class foo, can access public method bar out initializing fooobj
var foo = function(){ this.bar = function(){ console.log("i bar"); } } i know can access bar
var fooobj = new foo(); fooobj.bar(); in other object oriented language javeif declare bar static can access class name foo.bar
there no static concept java can like
var foo = function(){ // constructor specific code } foo.bar = function(){ console.log("i bar"); } this how singleton defined in javascript
Comments
Post a Comment