Learn Create Your Own Split Screen

Next Page

There's only one global scope, but there can be many different local scopes.

var myvar = 10; // a global myvar function func1 () { var myvar = 20; // a myvar which is local to func1 } function func2 () { var myvar = 30; // a myvar which is local to func2 } function func3 () { var myvar = 40; // a myvar which is local to func3 }
In this code fragment, there are four separate myvar variables. One is global, the other three are all local to their own functions.