For web browsers, we have a window object. It provides the browser window functionality and also plays the role of a global object. When scripts create global variables in the web browsers, they're created as members of the global object(window object).
In Node.js, This is not the case. NodeJs has something called global object.
Here are some facts:
- In the Node.js module system, each file is treated as a separate
module.
- The Global objects are available in all modules.
- While in browsers, the global scope is the window object, in nodeJS,
the global scope of a module is the module itself, so when you define a variable in the global scope of your Node.js module, it will be local to this module.
NodeJs:

Browser:
