What is DevRel? | What is Developer Relations ?
A to Z Full Forms and Acronyms

Javascript Runtime Environment

Jun 24, 2021 Javascript Runtime Environment, 650 Views
CRuntime Environment

Javascript Runtime Environment

We already know that JavaScript is a singlethreaded language, which means it has only one call stack that is used to execute the program. So, how can we execute heavy code without blocking the UI and making the browser unresponsive? Well, the solution is asynchronous callbacks. The below pictorial representation you can easily understand, behind the scenes of Javascript

The JavaScript  V8 Engine consists of two main components:

  1. Memory Heap: this is where the memory allocation happens
  2. Call Stack: this is where your stack frames are as your code executes

Within JS , we have WebAPIs ,Callback queue, and Event Loops that is used to run the JS code that is responsible for to achieve Async.

  1. Web API: this executes the timeout function and places the code in the callback queue
  2. Call Back Queue: these are queues that hold callback functions to asynchronous operations when they have been completed in the background.
  3. Eventloop: this checks if the call stack is empty or not or whether there is any statement in the callback queue that needs to be executed all the time

Try this below sample code

This example uses setTimeout to delay the printing of the log message by 2 seconds. And here setTimeout is part of the window object in the browse but not belongs to Javascript.

A to Z Full Forms and Acronyms
Nitin Pandit

Nitin Pandit

With over 10 years of vast development experience with different technologies, Nitin Pandit is Microsoft certified Most Valued Professional (Microsoft MVP) with a rich skillset that includes developing and managing IT/Web-based applications in different technologies, such as – C#.NET, ADO.NET, LINQ to SQL, WCF, and ASP.NET 2.0/3.x/4.0, WCF, WPF, MVC 5.0 (Razor), and Silverlight, along with client-side programming techniques, like jQuery and AngularJS. Nitin possesses a Master’s degree in Computer Science and has been actively contributing to the development community for its betterment. He has written more than 100 blogs/articles and 3 eBooks on different technologies to help improve the knowledge of young technology professionals. He has trained more than one lakh students and professionals, as a speaker in workshops and AppFests, conducted in more than 25 universities in North India.

Related Article

Cookies.

By using this website, you automatically accept that we use cookies. What for?

Understood