JavaScript under the hood Flashcards

Understanding how JavaScript works under the hood. JavaScript engine, parser, compiler, call stack, event loop, etc.

1
Q

What is IR?

A

Intermediate representation. It is bytecode generated by the interpreter from the AST.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Mention the steps that a JavaScript program goes through when executed

A

Source code -> AST -> IR -> Machine Code
The parser converts the source code into AST, the Ignition interpreter converts the AST into an IR and the TuboFan compiler converts the IR into machine code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is bytecode?

A

An abstraction of machine code. A form of instruction set designed for efficient execution by an interpreter. Also can be thought as an intermediate representation between the source code and the machine code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the GEC?

A

Global Execution Context.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the FEC?

A

Function Execution Context.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Execution context phases

A

Memory creation phase and execution phase.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What happens during the memory creation phase?

A
  1. The global object is created (browser = window, Node.js: global)
  2. “this” is created and binded to the global object.
  3. Setup memory heap for storing variables and function references.
  4. Store functions and variables in global execution context. Variables set to undefined.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What happens during the executing phase?

A
  1. Code gets executed line by line.
  2. Function execution context is created for each function call.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a literal?

A

A variable value written directly into the code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly