Menu
  • HOME
  • TAGS

Make object variables be accesible within all “deeper” scope

javascript,object,this,private-functions

Try this. var myConstructor = function() { this.one = "one"; this.two = "two"; this.publicMethod = function() { // new variable _two = this.two; console.log("I can access: ", this.one); var privateMethod = function() { console.log("I cannot access var two like this: ", _two); }; privateMethod(); }; }; ...