Question: if I declare a variable in on js fiile, is this available to another js file that is loaded?

Answer: yes, it's available (unless inside of a function or something)

BUT: does it matter WHERE I declare this variable??

Let's say, I have the following in my HTML file:

<script src="script/main.js"></script>

And then at the very bottom of my HTML page before the </body> tag I have:

<script type="text/javascript">var myvariable = "Sample Data";</script>

So, is myvariable available to main.js?

In simple tests I've done, yes it does seem to be available

But... what if I have a lot of other js code running in between
Does this change anything?

Thanks


OM