JS 02 What is a Promise in JavaScript

Published 2023-07-22
‪@ApplyIT2021‬ #applyit #javascript #programming #asyncawait
This video explains about promise object and its internal data. It also explains possible states of a promise and what transitions will occur when a promise gets fulfilled or gets rejected.

Watch previous video on Difference between blocking and non-blocking call using Analogy at
   • JS01 Sync vs Async call in JavaScript...  


In JavaScript, a Promise is a powerful and essential concept that simplifies asynchronous programming and improves code readability and maintainability. It is a representation of a value that might be available now, in the future, or never. Promises are commonly used for handling asynchronous operations like fetching data from a server, reading files, or executing time-consuming tasks.

A Promise is an object that wraps an asynchronous operation and returns the result (or error) when the operation completes. A Promise can be in one of three states:

Pending: The initial state when the Promise is created, and the asynchronous operation is still ongoing.
Fulfilled: The state when the asynchronous operation completes successfully, and the Promise holds a value.
Rejected: The state when the asynchronous operation fails, and the Promise holds a reason for the failure.

All Comments (1)