JavaScript under the hood Flashcards
Understanding how JavaScript works under the hood. JavaScript engine, parser, compiler, call stack, event loop, etc.
What is IR?
Intermediate representation. It is bytecode generated by the interpreter from the AST.
Mention the steps that a JavaScript program goes through when executed
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.
What is bytecode?
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.
What is the GEC?
Global Execution Context.
What is the FEC?
Function Execution Context.
Execution context phases
Memory creation phase and execution phase.
What happens during the memory creation phase?
- The global object is created (browser = window, Node.js: global)
- “this” is created and binded to the global object.
- Setup memory heap for storing variables and function references.
- Store functions and variables in global execution context. Variables set to undefined.
What happens during the executing phase?
- Code gets executed line by line.
- Function execution context is created for each function call.
What is a literal?
A variable value written directly into the code.