Why does JavaScript “this” returns different values in Node and Browser environments?
问题 After watching Kyle Simpson's Advanced JavaScript course on Pluralsight, I created a simple code snippet to try out this binding. I usually work in SublimeText editor and have node build engine configured in it and occasionally I run the same code in browser as well. I have noticed one difference in the program output when execute code in Node and in Browser [Chrome]. Following is the code snippet to try out this binding. function foo() { console.log(this.bar); } var bar = "bar1"; var obj =