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
Post a Comment