Js Notes Important
Js Notes Important
4. JavaScript is Single-Threaded:
JavaScript runs on a single thread, meaning it executes code one line at a time in a
synchronous manner.
Functions that are asynchronous (e.g., setTimeout, Promises, API calls) are not executed
immediately.
These functions do not block the main thread. Instead, they are handed off to external APIs
(like the browser's Web API or Node.js equivalents) for execution.
Page 1|3
Once an asynchronous operation is completed, the associated callback function (or the
resolved Promise) is sent to the event loop.
The event loop ensures that these callbacks are executed only when the main thread (call
stack) is empty.
Non-Blocking Nature:
JavaScript continues executing the rest of the code without waiting for asynchronous
operations to complete.
It is the language of web and it is used for creating and managing websites and web
applications. It is used to make web pages and web applications work dynamically
Page 2|3
Page 3|3