In this short video tutorial I explain what is meant by Lexical Scoping.
Sample code snippet used for explaining.
// Lexical Scope
// Code in one scope can access variables in same scope or any scope outside // of it.
// Global variables
let x = 2
// function with an inner function
function outerFn() {
let y = 9
// can access x, y
function innerFn () {
let z = 44
// can access x,y,z
console.log(x, y, z)
}
}