InterviewHubPRO
Section Overview
Q471

Question 471 of 521

Part 8: Modern JavaScript APIs, WeakRef, Proxy & Performance (464 - 521)

90%
JavaScript Internals (521 Qs)•Part 8: Modern JavaScript APIs, WeakRef, Proxy & Performance (464 - 521)

What is Lexical Scope?

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

js
 <script>
         function x(){
           var a=10;
           function y(){
               console.log(a); // will print a , because of lexical scope, it will first look 'a' in
           //its local memory space and then in its parent functions memory space
           }
           y();
       }
       x();
 </script>