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
Copy file name to clipboardExpand all lines: README.md
+21Lines changed: 21 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -500,6 +500,7 @@
500
500
| 462 |[What is inline caching?](#what-is-inline-caching)|
501
501
| 463 |[What are the different ways to execute external scripts?](#what-are-the-different-ways-to-execute-external-scripts)|
502
502
| 464 |[How to detect system dark mode in javascript?](#how-to-detect-system-dark-mode-in-javascript)|
503
+
| 465 |[What is Lexical Scope?](#what-is-lexical-scope)|
503
504
<!-- TOC_END -->
504
505
505
506
<!-- QUESTIONS_START -->
@@ -8738,6 +8739,26 @@ The execution context is created when a function is called. The function's code
8738
8739
8739
8740
**[⬆ Back to Top](#table-of-contents)**
8740
8741
8742
+
465. ### What is Lexical Scope?
8743
+
8744
+
Lexical scope is the ability for a function scope to access variables from the parent scope.
8745
+
8746
+
<script>
8747
+
function x(){
8748
+
var a=10;
8749
+
function y(){
8750
+
console.log(a); // will print a , because of lexical scope, it will first look 'a' in
8751
+
//its local memory space and then in its parent functions memory space
8752
+
}
8753
+
y();
8754
+
}
8755
+
x();
8756
+
</script>
8757
+
8758
+
**[⬆ Back to Top](#table-of-contents)**
8759
+
8760
+
<!-- QUESTIONS_END -->
8761
+
8741
8762
464. ### How to detect system dark mode in javascript?
8742
8763
8743
8764
The combination of `Window.matchMedia()` utility method along with media query is used to check if the user has selected a dark color scheme in their operating system settings or not. The CSS media query `prefers-color-scheme` needs to be passed to identify system color theme.
0 commit comments