In node.js, there is a global context, which is the equivalent of the window context in js on the client side. Declaring a variable outside of any closing module / function /, as in normal Javascript, will contain it in a global context, that is, as a global property.
I understand from your question that you want something similar to the following:
var something = 42; var varname = "something"; console.log(window[varname]);
This in node.js will become:
var something = 42; var varname = "something"; console.log(global[varname]);
source share