Javascript – How to find JavaScript variable by its name

javascript

Is there a way to find JavaScript variable on the page (get it as an object) by its name? Variable name is available as a string constant.

Best Solution

<script>
var a ="test";
alert(a);
alert(window["a"]);
alert(eval("a"));
</script>