in javascript objects, do "static" functions and prototype functions share same namespace? -


regardless of wisdom of such naming scheme, following valid?

 var f = function() {   this.f1 = function() {} } f.f1 = function() {}  // "static" call var v1 = f.f1();  // prototype call var f = new f(); var v2 = f.f1(); 

it seems should ok since, example, var , this variables within object function not share same space.

yes, valid.

in example, f function assign property called f1 function itself. if change code read f = new f(), f object inherits f's prototype, they're still 2 distinct objects.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -