A Promise in JavaScript is an object that represents the result of an asynchronous operation.
It helps handle tasks like:
API calls
File loading
Database requests
Timers (setTimeout)
Instead of waiting for the task to finish, JavaScript continues running other code.
Promise States
A Promise has 3 states:
Pending → Initial state
Resolved / Fulfilled → Operation successful
Rejected → Operation failed
Promise Methods
Method and Purpose
.then() -> Runs when promise is successful
.catch() -> Runs when promise fails
.finally() -> Runs always
output
Callback Hell.
output




Top comments (0)