Search⌘ K

Lexical Scope

Explore lexical scope in JavaScript to understand how functions can access variables from their parent scopes. Learn how lexical binding and the scope chain allow organized variable access, enabling better management of global and local scopes within your code.

We'll cover the following...

Background

There are two types of scopes: global and local. We have yet to explore exactly how local scopes draw boundaries between themselves. Additionally, JavaScript has some features that allow inner scopes to access values from the outer scope.

Introduction

Lexical scope is the ability for a function scope to access variables from ...