oop - Differences in function declarations in a Javascript constructor function -
i'm confused different ways declare functions inside constructor function.
function classname() { this.one = function() {}; var 2 = function() {}; 3 = function() {}; }
i know one public , can called outside , two private. semantics three?
the example have provided syntax error, need use =
assignment in context.
three
if used correct assignment operator global function exist outside of scope. when omit var
keyword, variable assigned property of global object, window
in browser.
when using var
, become properties of variableobject in execution context. use them normal variables.
Comments
Post a Comment