December 2014
Intermediate to advanced
272 pages
8h 17m
English
After you start adding conditions, functions, and loops to your JavaScript applications, you need to understand variable scoping. Variable scoping sets out to determine the value of a specific variable name at the line of code currently being executed.
JavaScript enables you to define both a global version and a local version of a variable. The global version is defined in the main JavaScript, and local versions are defined inside functions. When you define a local version in a function, a new variable is created in memory. Within that function, you reference the local version. Outside that function, you reference the global version.
To understand variable scoping a bit better, consider the code in Listing 1.4.
Read now
Unlock full access