JavaScript: Scope

JavaScript: Scope

English | MP4 | AVC 1280×720 | AAC 48KHz 2ch | 0h 41m | 74 MB

JavaScript scope determines how variables can be accessed throughout your code. There are two scopes: global and local. Global variables are accessible from anywhere; local variables are accessible only from within the function or block the variables are declared. Scope can be confusing, especially when factors such as hoisting and closures enter the mix. This course provides a thorough introduction to the scope options for JavaScript variables, alongside challenges that help you practice what you’ve learned. LinkedIn Learning instructor Emmanuel Henri helps you properly scope your variables, mitigate the effects of hoisting, and declare local variables inside non-function code such as if statements using block scope.

Topics include:

  • What is variable scope?
  • What are closures?
  • Global vs. local variables
  • Block-scoped variables
Table of Contents

Introduction
1 Learn how to properly scope your variables
2 Course prerequisites

Introduction to Variable Scope
3 Setup for this course
4 What is scope in JavaScript
5 What are closures
6 The different types of scope
7 Hoisting explained

Global Variables
8 What are global variables
9 Challenge – Define global variable
10 Solution – Define global variable

Local Variables
11 What are local variables
12 Challenge – Define local variable
13 Solution – Define local variable

Block-Scoped Variables
14 What are block-scoped variables
15 Explore block-scoped variables with code
16 Challenge – Define let const variables
17 Solution – Define let const variables

Conclusion
18 Next steps