var keyword in Browser vs var in Nodejs

In browsers, the top-level scope is the global scope. This means that within the browser var something will define a new global variable.

In Node.js this is different. The top-level scope is not the global scope;
var something inside a Node.js module will be local to that module.

global object in Nodejs:

There is a global object in Nodejs runtime that has all the global objects.You can add into that global object to define any global variable

or Simple don’t use var while declaring a variable.It will automatically go into global

Suffering from Knowledge Quest

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store