One way is to use the eval function
var theVariable = "bigToe"; var bigToe = "is broken"; console.log('my '+theVariable+' '+eval(theVariable));
Another way is to use a window object that contains a key-value pair for each global variable. It can be accessed as an array:
var theVariable = "bigToe"; var bigToe = "is broken"; console.log('my '+theVariable+' '+window[theVariable]);
Both methods print a response to the Firebug console.
DavidWinterbottom
source share