That doesn't sound like a node.js question -- more like browser javascript. This list isn't really the place for browser javascript questions, but let's see if this helps.
If it is indeed a browser question, you can use variables like that globally by making them properties of window:
Also variables at the top level (not wrapped in a function) in plain browser javascript are shared, so just the declaration will work.
However, if you use a module system like browserify, everything is wrapped in functions, so that doesn't work and you have to use the global "window" object.
Aria