For starters javascript runtime environment is not the javascript engine.
Javascript engine is inside the javascript runtime environment which is different for different implementations. A javascript engine which is most famous is V8 (Chrome and node.js), Mozilla uses Spidermonkey which was the first js engine.
Parsing👇
Here the code is broken down to smaller pieces known as tokens and is then transformed.
The code that is entered is turned into an abstract syntax tree.
Optimization & compilation👇
Javascript can be treated as both interpreted or compiled language. Spidermonkey treated it as an interpreted language for its fast use in browsers.
Nowadays, both are used, in just in time compiled javascript form.
The abstract syntax tree is broken down into bytes here and sent forward.
Execution👇
This is done along with the two of our favourite components of JS, Call Stack & Memory Heap.
The logic of different JS engine is different from one another. Some of the features that are combined to make the best out it are:
Inline caching: It takes note of the repeated calls to the same method that tend to occur on the same type of object.
Mark and Sweep: This is a garbage collection algorithm where the garbage collector does marking in first phase & sweeping in second.
All the reachable in use objects are ticked as true and marked while others are marked as 0. Then we sweeps the unreachable objects from heap memory.
For more on javascript runtime environment
🌟Understanding JRE
Top comments (0)