Skip to content

Commit f79c41e

Browse files
committed
first commit
0 parents  commit f79c41e

File tree

8 files changed

+113
-0
lines changed

8 files changed

+113
-0
lines changed

Closures/Closures.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Closure Definition:
2+
3+
4+
Closures have a lot of advantages and real -world examples:
5+
6+
1. Module Pattern
7+
2. Function Currying
8+
3. Higher Order Functions (memoize, ones)
9+
4. Data Hiding and Encapsulation
10+
11+
12+
Data Hiding and Encapsulation:
13+
->
14+
15+
Disadvantages of Closures:
16+
17+
-> Those closed variables are not garbage collected,
18+
-> If not handle properly, Memory can be leaked and browser can be freeezed.
19+
-> Closures consume so much Heap Memory Becuase those variables which are present inside the Closure Function can be Garbage collected.

Closures/Demonstartion/01 Closures.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
let num = 10;
2+
3+
const outer = () => {
4+
let num = 10;
5+
const inner = () => {
6+
// let num = 20
7+
const core = () => {
8+
console.log("In Core", num);
9+
};
10+
return core;
11+
};
12+
return inner;
13+
};
14+
15+
outer()()();

Closures/Demonstartion/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<title>Closures</title>
9+
</head>
10+
11+
<body>
12+
<h1>Javascrip: Closures</h1>
13+
<script defer src="./01 Closures.js"></script>
14+
</body>
15+
16+
</html>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
What is a Callback Function in Javascript
2+
3+
-> You can take a function which can be passed into another function, the function which has been passed is called CallBack Function.
4+
5+
-> With the help of "callback" functions, we can do "asynchronous" tasks in a synchronous - single threaded Javascript.
6+
7+
Example: setTimeout(handler, delay);
8+
"handler is the call back function."
9+
10+
Power of a Callbacks?
11+
12+
Deep about the Event Listeners?
13+
14+
document.getElementById("clickMe")
15+
.addEventListener("click", function cb(){
16+
console.log("Button Clicked!");
17+
})
18+
19+
20+
-> Even Listeners are heavy, It consumes the Memory. The program can't free up the Memory which stores the Event Listeners.
21+
e.g., onclicke, onclose, onscroll, onhover
22+

Functions/Higher-Order Fn().txt

Whitespace-only changes.

Namaste-JS-Planning.xlsx

9.82 KB
Binary file not shown.

Need-To-Cover.jpg

178 KB
Loading

Random-Notes.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Akshay's Suggestions:
2+
-> ECMASCRIPT 6 Standards Documentation,
3+
4+
What is Lexical Environment?
5+
Whenever Global Execution Context is created, the Lexical Environment is also created. Lexical environment is a local memory along with the lexical environment of it's parent.
6+
7+
-> Lexical means "in heirarchy" or "in a sequence".
8+
9+
function a(){
10+
var b= 10;
11+
c();
12+
function c(){
13+
...
14+
}
15+
}
16+
17+
a();
18+
19+
-> c func() is lexically inside a func().
20+
-> where that code is present physically inside where?
21+
-> a func() is lexically inside the global scope.
22+
23+
-> Local Memory along with Lexical environment of it's Parent.
24+
25+
-> Whenever the Global Execution Context is created, then in the Memory Allocation part, The reference of the Local Memory as well as Lexical Environment of it's Parent also been created.
26+
27+
-> Scope Chaining is the chain of all the lexical environments of it's parent's references.
28+
29+
-> Lexical Environment = Local Memory + Lexical Environment of it's Parent(where it's lexically present).
30+
31+
-> Scope is defined that, whether a function or variable present inside the Scope Chain.
32+
33+
34+
35+
***Anonymous Function, First Class Function, and Higher Order Function, Call Back Function***
36+
37+
***Function Statement, Function Expression and Function Declaration.***
38+
39+
Answers:
40+
41+
->

0 commit comments

Comments
 (0)