File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > Execution Context</ title >
7+ </ head >
8+ < body >
9+ < h1 > Execution Context</ h1 >
10+
11+ < script >
12+ /*
13+ # Execution Context:
14+ - An environment where JS code runs
15+ - Provided by JavaScript Engine
16+ - Types of execution contexts:
17+ - Global Execution Context (GEC)
18+ - Function Execution Context(s) (FEC)
19+ - 2 Phases in which JS execution happens:
20+ - Memory allocation phase
21+ - Code execution phase
22+
23+ - Resources:
24+ - JS visualizer: https://pythontutor.com/visualize.html#mode=edit
25+
26+ # JavaScript Memory:
27+ - Types
28+ - Stack Memory: Primitive values
29+ - Heap Memory: Non-Primitive values
30+
31+ - Primitive vs Non-primitive assignement
32+ - Primitive: Value gets assigned
33+ - Non-primitive: Reference assigned
34+ */
35+
36+ /* ----------------------------- */
37+ // var num1 = 10
38+ // var num2 = 20
39+ // console.log(num1 + num2)
40+
41+ // Current phase running: CODE EXECUTION
42+ // JS Memory
43+ // GEC
44+ // num1: 10
45+ // num2: 20
46+
47+ /* ----------------------------- */
48+ // var x = 20
49+ // var y = 40
50+
51+ // function sum() {
52+ // var num1 = 50
53+ // var num2 = 100
54+ // console.log(num1 + num2)
55+ // }
56+
57+ // console.log(x + y)
58+ // sum()
59+
60+
61+ // // Current phase running: CODE EXECUTION
62+ // // JS Memory
63+ // // GEC
64+ // x: 20
65+ // y: 40
66+ // // FEC (sum)
67+ // num1: 50
68+ // num2: 100
69+ </ script >
70+ </ body >
71+ </ html >
You can’t perform that action at this time.
0 commit comments