JavaScript new keyword and objects scopes
Later today, I was scrolling through ejhon.com slides and I found out the following: Give this code function katana () { this.myvar = true; } katana (); console.info (myvar); Past the moment I compiled the code, I thought that myvar is attached to the katana function. Actually, it gets attached to the window objects, which pollutes the global namespace. I returned to my projects, which all uses the same approach.. a little bit differently function katana () { this.myvar = true; } var xyz = new katana(); console.info (myvar); I have a function object and instead of executing the function, I