Why does the function bar have access to variable a?

Refer to the code below:

function foo () {

const a =2;

function bat() {

console.log(a);

}

return bar;

}

Why does the function bar have access to variable a?
A . Inner function’s scope
B. Hoisting
C. Outer function’s scope
D. Prototype chain

Answer: C

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments