Where are globals stored in Node.JS? Is there a window-like object in Node?


If I write:

myVar = 123; // note the missing var keyword

is there an object in NodeJs where I can retrieve this variable from?

In a browser this would be:

Problem courtesy of: Gabriel Petrovay


Node's globals are stored in the global variable and is documented here. Since "global" variables are local to each module, global is the true global variable that is shared across modules.

Solution courtesy of: hexacyanide


They are stored in the global object

Discussion courtesy of: tymeJV

This recipe can be found in it's original form on Stack Over Flow.