<script>
//in one script
var someVarName_10 = 20;
</script>
I want to get access to this variable from another script by name of variable. With window object its simple, is it possible with local variable?
I mean access this var by code like this:
<script>
alert(all_vars['someVar' + 'Name' + num]);
</script>
Do you want to do something like this?
Update: because OP edited the question.
well, for debugging purpose only, you could do something like this. I use it during the development of classes, where some variables must remain private (var). this work even in local variable (and global of curse)
I've noticed that everyone is advising global var creation this will lead to variables leak to global namespace. When you dynamically creating classnames or just variables it's easy to keep em local:
or
Name-spacing would look like this:
If this is what you said:
It works because script are finally available to the document and you can access their vars.