Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 161998b

Browse files
committed
Aded table of Content
1 parent 46b781e commit 161998b

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

‎01-Javascript-Engine.md‎

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
**Table of Content**
2+
3+
- [JavaScript Engine](#javascript-engine)
4+
- [How engine works? (Summary)](#how-engine-works-summary)
5+
- [Inside the JavaScript Engine](#inside-the-javascript-engine)
6+
- [Compilation](#compilation)
7+
- [Interpretation](#interpretation)
8+
- [Just in Time (JIT) compilation in JavaScript](#just-in-time-jit-compilation-in-javascript)
9+
- [Call Stack and Memory Heap](#call-stack-and-memory-heap)
10+
- [Call Stack](#call-stack)
11+
- [Memory Heap](#memory-heap)
12+
- [Stack vs Heap](#stack-vs-heap)
13+
- [References in JavaScript](#references-in-javascript)
14+
- [Garbage Collection](#garbage-collection)
15+
- [Execution Context](#execution-context)
16+
- [Types of Execution Context](#types-of-execution-context)
17+
- [Execution Stack](#execution-stack)
18+
- [Creation of Execution Stack](#creation-of-execution-stack)
19+
- [Lexical Environment](#lexical-environment)
20+
- [Hoisting](#hoisting)
21+
- [Hoisting with let/cosnt](#hoisting-with-letcosnt)
22+
- [Temproal Dead Zone](#temproal-dead-zone)
23+
124
# JavaScript Engine
225

326
JavaScript engine is a software or a program responsible to run our JavaScript code. Almost every modern day browsers we use have their own JavaScript engine running in the background. Some of the most popular JavaScript engine are -
@@ -33,9 +56,9 @@ Although most people consider JavaScript as an interpreted language, that is no
3356

3457
In this approach, whole program gets compiled into machine language at once and then it is executed. Unlike the compiled language like C, where the compilation is done ahead of time (before actual execution of code), with JavaScript, the compilation is done during execution.
3558

36-
### Call Stack and Memory Heap
59+
## Call Stack and Memory Heap
3760

38-
#### Call Stack
61+
### Call Stack
3962

4063
JavaScript is a single-threaded language i.e. it has only one call stack and it can process one statement at time. The call stack keeps track of functions to be executed. Call Stack follows the **Last in, First Out** principle which means it always process the call on top of the stack at first.
4164

@@ -82,25 +105,25 @@ The call stack is empty now and the final output would look like this:
82105
"I am a robot.";
83106
```
84107

85-
#### Memory Heap
108+
### Memory Heap
86109

87110
JavaScript stores objects and functions in heap. Unlike stack, JavaScript engine doesn't allocate a fixed memory for these objects. Instead, more spaces will be allocated as needed. This is called the **dynamic memory allocation.**
88111

89-
#### Stack vs Heap
112+
### Stack vs Heap
90113

91-
##### Stack
114+
**Stack**
92115

93116
- Primitive values and references
94117
- Size is known at compile time
95118
- Allocates a fixed amount of memory.
96119

97-
#### Heap
120+
**Heap**
98121

99122
- Objects and functions
100123
- Size is known at run time
101124
- No size limit per object
102125

103-
#### Examples
126+
**Examples**
104127

105128
```js
106129
const myProfile = {
@@ -131,7 +154,7 @@ JavaScript not only allocate memory for objects, they also release the memory. O
131154

132155
Execution Context is an concept of an environment where JavaScript code is evaluated and executed.
133156

134-
#### Types of Execution Context
157+
### Types of Execution Context
135158

136159
- **Global Execution Context** : This is the default execution context. It does two thing: **_creates a global object (window object) and sets the value of *this* to global object._**
137160

@@ -155,7 +178,7 @@ ExecutionContext = {
155178
}
156179
```
157180

158-
#### Lexical Environment
181+
### Lexical Environment
159182

160183
Lexical Environment is a structure that holds identifier-variable mapping. (_identifier refers to name of variables/functions and the variable is reference to actual object including function object and array object_).
161184

@@ -186,7 +209,7 @@ Each Lexical Environment has three component:
186209
- Reference to outer environment
187210
- _this_ binding
188211

189-
### Hoisting
212+
## Hoisting
190213

191214
Hoisting is the default behavior of JavaScript where it defines all the declarations at the top of scope before code execution. JavaScript only hoists declarations, not initialization.
192215

@@ -302,6 +325,6 @@ But the error "cannot access before initialization" means our JS engine knows th
302325
303326
_To summarize, variables declared with **let** or **const** are hoisted **without** a default initialization but the variables declared with **var** are hoisted **with** default initialization of undefined._
304327
305-
#### Temproal Dead Zone
328+
### Temproal Dead Zone
306329
307330
This is a period during execution where _let/const_ variables are hoisted but not accessible.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /