Skip to content

JavaScript Engine

المعرفة:: JavaScript
الحالة:: ملاحظة_مؤرشفة
المراجع:: syahshiimi’s notes, The Complete JavaScript Course 2022 From Zero to Expert


How the JavaScript Engine is executed is through the call stack and the heap.

Compilation vs Interpretation

Compilation

An entire code is converted into machine code and later executed via a binary file.

Interpretation

  • The interpreter runs through the source code and instead only executed all at the same time. It is only run before it was executed.
  • Interpreted languages are often slower.
  • Modern JavaScript engine uses a mix of both compilation and interpreted approaches known as just in time compilation. It is compiled beforehand into machine code and executed just on time.

JavaScript Engine

Step One: Parsing is also known as ‘reading the code’.

Step Two: Compilation via the AST

  • AST: Abstract Syntax Tree.
  • It has nothing to do with DOM.

Step Three: Execution

This step happens in the call stack.

Step Four: Optimization

The Engine optimizes the execution continuously.

What is a JavaScript Runtime?

  • We can imagine a JavaScript runtime as a huge box which includes all the important stuff we need to run the code.
  • In order to work properly, WEB API’s offer greater functionalities but are not part of the JavaScript Runtime.
  • A typical JavaScript Runtime also includes a callback queue. This functions allows us or attach event handlers to DOM elements and these are also called callback functions.

Last update : August 14, 2023
Created : August 23, 2022

Comments

Comments