Javascript Runtime Env
JS runtime environment is where our javascript code will be executed.
JS Runtime (as implemented in a browser) comprises of below modules or parts or components.
Web APIs
JS Engine(like Chromium's v8 engine)
Call or Execution Context stack
Event loop / Callback Queue
Microtask Queue
Javascript => Single Threaded language => which means it has a single call stack => it can do one thing at a time
JS Engine
= program which compiles, parses and executes a Javascript code
as it starts executing a JS code, it will create:
=> a Memory Heap and a Call stack
Memory Heap = an unstructured memory pool
= where it will store variables, objects from the code
Call Stack = stack of code instructions that JS Engine finds in the code when it starts executing it from top to bottom
= where JS code gets executed using execution contexts
= a stack of Execution contexts = a Global Env. Context + other execution contexts as they are created and removed for each function or curly bracket pairs
= an API of functions to allow javascript code to interact with browser or use browser's functionality (for e.g. console, setTimeout, the DOM object and its various functions, fetch etc.)
= provided by browser
= therefore, Web API objects and functions can be used in javascript code
= a data structure that contains all the callback functions that are ready to be executed
It stores special callback functions which have higher priority than the callback function waiting in the callback queue
Last updated