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

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -