You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can not access variables which are defined within a function
(function(){vara=3;})();console.log(a);// to access a you must define it outside of the functionleta;(function(){a=3;})();console.log(a);// create global variable inside of function without declare it before(function(){vara=b=3;})();console.log(a);console.log(b);// 3
Child Objects share this of parent Object
varmyObject={foo: "bar",func: function(){varself=this;console.log("outer func: this.foo = "+this.foo);// barconsole.log("outer func: self.foo = "+self.foo);// bar(function(){console.log("inner func: this.foo = "+this.foo);// undefined because of new functionconsole.log("inner func: self.foo = "+self.foo);// bar}());}};myObject.func();