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.

jsfiddle.

when using var, become properties of variableobject in execution context. use them normal variables.

further reading.


Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -