by kirupa | 20 February 2014
Let's revisit something relating to variables. Each variable you declare has a certain level of visibility that determines when you can actually use it. In human-understandable terms, what this means is simple. Just because you declare a variable doesn't mean that it can be accessed from anywhere in your code. There are some basic things you need to understand, and this whole area of understanding this falls under a topic known as variable scope.
This is a companion discussion topic for the original entry at http://www.kirupa.com/html5/variable_scope_js.htm