Skip to content

Commit 3da1956

Browse files
Updated The Layout and Bit of Changes
1 parent 59973ec commit 3da1956

18 files changed

Lines changed: 314 additions & 56 deletions

01_JavaScript_Fundamentals.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 👋 Hello, World!
1+
# CHAPTER 01: 👋 Hello, World!
22

33
## 🧩 The `<script>` Tag
44

@@ -124,3 +124,11 @@ Use separate `<script>` tags instead:
124124
```
125125

126126
---
127+
128+
<br><br>
129+
130+
<p align="right">
131+
<a href="./02_Code_Structure.md"><b>GO TO NEXT ›</b></a>
132+
</p>
133+
134+
---

02_Code_Structure.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 🧱 JavaScript Code Structure
1+
# CHAPTER 02: 🧱 JavaScript Code Structure
22

33
The building blocks of code.
44

@@ -15,7 +15,8 @@ alert("Hello, world!");
1515
We can have as many statements in our code as we want. They can be separated with a semicolon (`;`):
1616

1717
```js
18-
alert("Hello"); alert("World");
18+
alert("Hello");
19+
alert("World");
1920
```
2021

2122
But usually, for readability, we write them on separate lines:
@@ -34,8 +35,8 @@ Semicolons can be **omitted** in many cases where a line break exists:
3435
This would also work:
3536

3637
```js
37-
alert("Hello")
38-
alert("World")
38+
alert("Hello");
39+
alert("World");
3940
```
4041

4142
Here, JavaScript interprets the line break as an **implicit** semicolon. This is called **automatic semicolon insertion**. But be careful—**not all cases** are safe.
@@ -45,9 +46,7 @@ Here, JavaScript interprets the line break as an **implicit** semicolon. This is
4546
Example:
4647

4748
```js
48-
alert(3 +
49-
1
50-
+ 2);
49+
alert(3 + 1 + 2);
5150
```
5251

5352
✅ This works as expected and shows `6` because JavaScript does not insert semicolons here. JavaScript knows the line ends in `+`, so it continues.
@@ -71,12 +70,10 @@ Hello
7170
But if you remove the semicolon after the `alert`:
7271

7372
```js
74-
alert("Hello")
75-
76-
[(1, 2)].forEach(alert);
73+
alert("Hello")[(1, 2)].forEach(alert);
7774
```
7875

79-
It fails!
76+
It fails!
8077
The difference compared to the code above is only one character: the semicolon at the end of the first line is gone.
8178

8279
If we run this code, only the first Hello shows (and there’s an error, you may need to open the console to see it). There are no numbers any more.
@@ -151,3 +148,17 @@ alert('World');
151148

152149
- Single-line comment: `Ctrl + /` (or `Cmd + /` on Mac)
153150
- Multiline comment: `Ctrl + Shift + /` (or `Cmd + Option + /` on Mac)
151+
152+
---
153+
154+
<br><br>
155+
156+
<p align="left">
157+
<a href="./01_JavaScript_Fundamentals.md"><b>‹ GO TO PREVIOUS</b></a>
158+
</p>
159+
160+
<p align="right">
161+
<a href="./03_The_Modern_Mode_use_strict.md"><b>GO TO NEXT ›</b></a>
162+
</p>
163+
164+
---

03_The_Modern_Mode_use_strict.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 🛡️ JavaScript Strict Mode – `"use strict"`
1+
# CHAPTER 03: 🛡️ JavaScript Strict Mode – `"use strict"`
22

33
## 📜 What is `"use strict"`?
44

@@ -103,3 +103,17 @@ But… when you start using **classes** or **modules**, strict mode is enabled a
103103
---
104104

105105
Stay strict, code safe! 💻🔒
106+
107+
---
108+
109+
<br><br>
110+
111+
<p align="left">
112+
<a href="./02_Code_Structure.md"><b>‹ GO TO PREVIOUS</b></a>
113+
</p>
114+
115+
<p align="right">
116+
<a href="./04_Execution_Context.md"><b>GO TO NEXT ›</b></a>
117+
</p>
118+
119+
---

04_Execution_Context.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Episode 1 : Execution Context
1+
# CHAPTER 04: Execution Context
22

33
### Everything in JS happens inside the **execution context.**
44

5-
Assume execution context to be a big box/container where everything takes place(whole javascript code is executed).
5+
Assume execution context to be a big box / container where everything takes place(whole javascript code is executed).
66

77
It has 2 components in it:
88

9-
<li> <strong>Memory : </strong>The place where all the variables and functions are stored as (key:value) pairs. Memory component is also known as <em>variable environment</em>.
10-
<li> <strong>Code : </strong>The place where code is executed one line at a time. Code component is also known as <em>Thread of Execution</em>
9+
- **Memory:** The place where all the variables and functions are stored as (key:value) pairs. Memory component is also known as _variable environment_.
10+
- **Code:** The place where code is executed one line at a time. Code component is also known as _Thread of Execution_
1111

1212
<br>
1313

@@ -16,5 +16,19 @@ _Javascript is not possible without this beautiful execution context._
1616

1717
### JS is a **synchronous single-threaded language**.
1818

19-
<li> By single threaded, we mean JS can only run 1 command at a time
20-
<li> By synchronous single threaded, we mean it can run 1 command at a time, <em>in a specific order</em>
19+
- By single threaded, we mean JS can only run 1 command at a time
20+
- By synchronous single threaded, we mean it can run 1 command at a time, **_in a specific order_**
21+
22+
---
23+
24+
<br><br>
25+
26+
<p align="left">
27+
<a href="./03_The_Modern_Mode_use_strict.md"><b>‹ GO TO PREVIOUS</b></a>
28+
</p>
29+
30+
<p align="right">
31+
<a href="./05_Execution_Context_And_Call_Stack.md"><b>GO TO NEXT ›</b></a>
32+
</p>
33+
34+
---

05_Execution_Context_And_Call_Stack.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Episode 2 : Execution & Call Stack
1+
# CHAPTER 05: Execution & Call Stack
22

33
**What happens when we run a js program?**
44

@@ -16,7 +16,7 @@ var square2 = square(n);
1616
var square4 = square(4);
1717
```
1818

19-
Now first, for this entire code a <strong>Global</strong> execution context is created.
19+
Now first, for this entire code a **Global** execution context is created.
2020

2121
So, this execution context is created in 2 phases:
2222

@@ -28,7 +28,7 @@ So, this execution context is created in 2 phases:
2828
Here JS will allocate memory to all the variables and functions whenever they are encounterd while running whole js program line by line. In case of variables, it stores a special value called _undefined_, and in case of functions it literally stores the whole code of the function inside this memory space.
2929

3030
- Memory is allocated to variables and functions.
31-
- For variable name(which is key) it assigns a value of <strong>undefined</strong>
31+
- For variable name(which is key) it assigns a value of **undefined**
3232
- For the function name(which is key) it assigns the entire function code as value.
3333

3434
```javascript
@@ -56,3 +56,17 @@ To manage all these EC, a **call stack** is created. Everytime code is run, the
5656
> Call Stack maintains the order of execution of execution contexts
5757
5858
#### Call stack also known as Execution control stack, program stack, control stack, runtime stack and machine stack
59+
60+
---
61+
62+
<br><br>
63+
64+
<p align="left">
65+
<a href="./04_Execution_Context.md"><b>‹ GO TO PREVIOUS</b></a>
66+
</p>
67+
68+
<p align="right">
69+
<a href="./06_Hoisting.md"><b>GO TO NEXT ›</b></a>
70+
</p>
71+
72+
---

06_Hoisting.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Episode 3 : Hoisting
1+
# CHAPTER 06: Hoisting
22

33
## Code Example 01
44

@@ -60,7 +60,11 @@ Output:
6060
- Not defined: We have not initialised the value for variable anywhere in the entire code and in memory space.
6161
- Undefined: It is a placeholder that is assigned to a variable by the Javascript Engine until the variable is assigned with some other value.
6262

63-
**Hoisting** is a concept which enables us to extract values of variables and functions even before initialising/assigning value without getting _error_
63+
---
64+
65+
**`Hoisting`** is a concept which enables us to extract values of variables and functions even before initialising/assigning value without getting _error_
66+
67+
---
6468

6569
<br>
6670

@@ -134,3 +138,17 @@ Output:
134138
- The answer lies in the Global Execution Context. In the memory phase, the variables will be initialized as _undefined_ and functions will get the whole function code in their memory.
135139

136140
- This is the reason why we are getting these outputs.
141+
142+
---
143+
144+
<br><br>
145+
146+
<p align="left">
147+
<a href="./05_Execution_Context_And_Call_Stack.md"><b>‹ GO TO PREVIOUS</b></a>
148+
</p>
149+
150+
<p align="right">
151+
<a href="./07_Functions_And_Variable_Environment.md"><b>GO TO NEXT ›</b></a>
152+
</p>
153+
154+
---

07_Functions_And_Variable_Environment.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Episode 4 : Functions and Variable Environments
1+
# CHAPTER 07: Functions and Variable Environments
22

33
```javascript
44
var x = 1;
@@ -31,12 +31,34 @@ Outputs:
3131
### Code Flow
3232

3333
- The Global Execution Context (GEC) is created (the big box with Memory and Code subparts). Also GEC is pushed into Call Stack
34+
3435
> Call Stack : GEC
36+
3537
- In first phase of GEC (memory phase), variable `x:undefined` and `a` and `b` have their entire function code as value initialized
3638
- In second phase of GEC (execution phase), when the function is called, a new local EC is made. After `x = 1` assigned to GEC `x`, `a()` is called. So local EC for a is made inside code part of GEC.
39+
3740
> Call Stack: [GEC, a()]
41+
3842
- For local EC, a totally different `x` variable assigned `undefined` (`x` inside `a()`) in phase 1 , and in phase 2 it is assigned `10` and printed in console log. After printing, no more commands to run, so `a()` local EC is removed from both GEC and from Call stack
43+
3944
> Call Stack: GEC
45+
4046
- Cursor goes back to `b()` function call. Same steps repeat.
47+
4148
> Call Stack :[GEC, b()] -> GEC (after printing yet another totally different x value as 100 in console log)
49+
4250
- Finally GEC is deleted and also removed from call stack. Program ends.
51+
52+
---
53+
54+
<br><br>
55+
56+
<p align="left">
57+
<a href="./06_Hoisting.md"><b>‹ GO TO PREVIOUS</b></a>
58+
</p>
59+
60+
<p align="right">
61+
<a href="./08_window_And_this.md"><b>GO TO NEXT ›</b></a>
62+
</p>
63+
64+
---

08_window_And_this.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Episode 5: Window and this keyword
1+
# CHAPTER 08: Window and this keyword
22

33
### Everywhere JS is run, it is done with a JS execution engine. For Chrome: v8
44

@@ -7,6 +7,7 @@
77
- It creates the GEC, the "window" and the _this_ variable.
88
- Window is a big global object that has a lot of functions and variables, which is created along with global execution context.These functions and varibles are created by the JavaScript Engine and into the global scope. All of these can be accessed from anywhere in the program.
99
- At the global level, _this_ points to _window_ object.
10+
1011
> this === window -> true (at global level)
1112
1213
_Whenever a JavaScript program is run, a **global object** is created, a **global execution context** is created and along with it a **this** varible is also created._
@@ -28,5 +29,19 @@ console.log(a); //also gives same "a" value. (if we don't put any . in front of
2829
console.log(x); // x is not defined. (tries to find x inside global space, but it isn't there)
2930
```
3031

31-
- Global space is anything in JS which isn't inside a function. All these global objects will be present inside the windows schema. But non globals ones won't be there (here, x)
32+
- Global space is anything in JS which isn't inside a function. All these global objects will be present inside the windows schema. But non globals ones won't be there (here, `x`)
3233
- When a GEC is made, _this_ is also created with it (even for functional(local) EC). Global object provided by the browser engine is the window, so _this_ points to window.
34+
35+
---
36+
37+
<br><br>
38+
39+
<p align="left">
40+
<a href="./07_Functions_And_Variable_Environment.md"><b>‹ GO TO PREVIOUS</b></a>
41+
</p>
42+
43+
<p align="right">
44+
<a href="./09_undefined_vs_not_defined.md"><b>GO TO NEXT ›</b></a>
45+
</p>
46+
47+
---

09_undefined_vs_not_defined.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Episode 6: Undefined vs Not Defined
1+
# CHAPTER 09: Undefined vs Not Defined
22

33
- In first phase (memory allocation) JS assigns each variable to a placeholder called _undefined_
44
- _undefined_ is when memory is allocated for the variable, but no value is assigned yet.
@@ -20,5 +20,19 @@ console.log(a);
2020
25
2121
Uncaught ReferenceError: a is not defined
2222

23-
- JS is a loosely-typed / weakly-typed language. It doesn't attach variables to any datatype. We can say var a = 5, and then change the value to bool (a = true) or string (a = 'hello') later on.
23+
- JS is a loosely-typed / weakly-typed language. It doesn't attach variables to any datatype. We can say `var a = 5`, and then change the value to bool (`a = true`) or string (`a = 'hello'`) later on.
2424
- **Never** assign _undefined_ to a variable manually. Let it happen on it's own accord.
25+
26+
---
27+
28+
<br><br>
29+
30+
<p align="left">
31+
<a href="./08_window_And_this.md"><b>‹ GO TO PREVIOUS</b></a>
32+
</p>
33+
34+
<p align="right">
35+
<a href="./10_Scope_And_Lexical_Environment.md"><b>GO TO NEXT ›</b></a>
36+
</p>
37+
38+
---

0 commit comments

Comments
 (0)