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

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -