Skip to content

Instantly share code, notes, and snippets.

@GuillermoPena
Created May 28, 2014 10:10
Show Gist options
  • Save GuillermoPena/93bd97c72d455bbf50ce to your computer and use it in GitHub Desktop.
Save GuillermoPena/93bd97c72d455bbf50ce to your computer and use it in GitHub Desktop.
NodeJS - Variables with dynamic name
var varName1 = "varName2"
global[varName1] = "Hello World" // This is the important line ;)
var staticVarName = global[varName1]
console.log("Var1: Name/Value : varName1/" + varName1)
console.log("Var2: Name/Value : " + varName1 + "/" + global[varName1])
console.log("Static Var: Name/Value : staticVarName/" + staticVarName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment