From what I understood from "this" explanation is that it returns "where" it got executed. So if it gets executed inside an object it returns that object. And if it gets executed in the global scope, it returns window object in the browser console and the global object in node. However, I am trying to console.logging "this" but it returns an empty object instead of the global one.
Asked
Active
Viewed 34 times
1

ModyDz
- 115
- 8
-
`this` in module scope in NodeJS isn't bound to the global object. It's bound to the module. – Nick Bailey Mar 07 '22 at 17:31