You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// -> Lexical scope in JavaScript means that the scope of a variable is determined by its position within the source code's lexical structure (the location where the variable is declared or defined).
7
+
// -> When a function is defined, it captures its surrounding lexical environment(scope chain) at the time of its creation.
8
+
9
+
// Why
10
+
// -> Clarity and Predictability: Helps developers understand where variables are defined and how they are accessed.
11
+
// -> Encapsulation: Enables functions to access variables from their containing scope, promoting modular and maintainable code.
12
+
// -> Closure: Facilitates the creation of closures, where inner functions retain access to variables in their lexical scope even after the outer function has finished executing.
0 commit comments