O'Reilly logo

JavaScript Absolute Beginner’s Guide by Kirupa Chinnathambi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7. Variable Scope

In This Chapter

Understand global scope

Familiarize yourself with the various techniques available for using local scope

Learn about some quirks that might cause your code to behave unpredictably

Let’s revisit something relating to variables that we saw in Chapter 2, “Values and 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 falls under a topic known as variable scope.

In this chapter, I explain variable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required