I want to create a log function where I can insert variable names like this:
var a = \'123\', b = \'abc\'; log([a, b]);
And the result sho
You can't access the variable names using an Array. What you could do is use objects or pass the variable names as a String:
var x = 7; var y = 8; function logVars(arr){ for(var i = 0; i < arr.length; i++){ alert(arr[i] + " = " + window[arr[i]]); } } logVars(["x","y"]);