I have a variable as such:
var foo = ["cool", "cool"];
How do I get the variable name, foo, as a string? In other words, given foo, how do I get "foo"? I want to use it in the following context where "foo" is used in getElementById(...):
document.getElementById("foo").innerHTML = document.getElementById("foo").innerHTML + "";
Thanks!
window). You might want to consider using an Object instead; i.e.var o = {foo: ["cool", "cool"]};Now say you havevar x = o.foo;you can iterate overoto findkeyusingo[key] === xfoois never used.