JavaScriptQuestion 14 of 36
What is a scope chain?
Answer out loud or in your head first, then compare.
Answer
JavaScript looks for a variable in the current scope first, then further and further out.
JavaScript
const a = 1;
function outer() {
const b = 2;
function inner() {
const c = 3;
console.log(a, b, c);
}
inner();
}For inner:
c → local scope
b → outer scope
a → global scopeThat is the scope chain.
How did it go? Be honest — “Not yet” puts the question on your review list.