Skip to content

Commit c6bff48

Browse files
authored
Merge pull request #289 from muazimmaqbool/master
New Question Added
2 parents adf2885 + e63b22b commit c6bff48

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@
500500
| 462 | [What is inline caching?](#what-is-inline-caching) |
501501
| 463 | [What are the different ways to execute external scripts?](#what-are-the-different-ways-to-execute-external-scripts) |
502502
| 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) |
503504
<!-- TOC_END -->
504505

505506
<!-- QUESTIONS_START -->
@@ -8738,6 +8739,26 @@ The execution context is created when a function is called. The function's code
87388739
87398740
**[⬆ Back to Top](#table-of-contents)**
87408741
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+
87418762
464. ### How to detect system dark mode in javascript?
87428763
87438764
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

Comments
 (0)