Variable Scope
If a variable is declared inside of a function with var, then it is only locally available to that function. If it is declared without var then it is globally available.
If a variable is declared outside of a function with var, then it is not available inside of functions. If it is declared without var then it is globally available.
Examples
<script type="text/javascript">
var somevar = "i am locally available";
andanother = "i am global";
function foobar()
{
var myvar = "i am local to this function";
anothervar = "i am global";
}
</script>
[Click to add or edit comments])
Please prepend comments below including a date