0

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:

window.myVar
Gabriel Petrovay
  • 20,476
  • 22
  • 97
  • 168
  • Why do you want to do use global variables? I assume you have a reason, but it's worth discussing for the benefit of future traffic to this page. – Richard Marr Oct 11 '13 at 17:25
  • I want to test if the Jade template engine is leaking global variables when writing `- myVar = 123` in a template ;) – Gabriel Petrovay Oct 11 '13 at 17:29

2 Answers2

3

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.

hexacyanide
  • 88,222
  • 31
  • 159
  • 162
1

They are stored in the global object

tymeJV
  • 103,943
  • 14
  • 161
  • 157