JavaScript Concurrency Model
JavaScript is a single threaded programming language. This means that only one piece of code can run at a time, on a single main thread, and everything else is blocked until an operation completes.
But we don’t want to wait or get blocked for a certain asynchronous task to complete! Imagine scrolling through Instagram and not able to actually scroll until a particular feed is loaded completely. That would be really awful!
Luckily, JavaScript is a non-blocking language, and this article is all about how things work under the hood.
Before we get into how JavaScript handles asynchronous tasks, one should know how exactly JavaScript code executes.
Execution context_ is an abstract concept that holds information about the environment within which the current code is being executed._
Basically, 2 things happen(simultaneously) whenever a JavaScript code is executed in a given execution context —
#coding #js #asynchronous #javascript #concurrency #programming