A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-promise-reference/ below:

JavaScript Promise Reference - GeeksforGeeks

JavaScript Promise Reference

Last Updated : 23 Jul, 2025

JavaScript Promise is used to handle asynchronous operations JavaScript. They are easy to manage when dealing with multiple asynchronous operations where callbacks can create callback hell leading to unmanageable code. Promises are the ideal choice for handling asynchronous operations in the simplest manner. They can handle multiple asynchronous operations easily and provide better error handling than callbacks and events.

Syntax

Promise.function();

Example:

JavaScript
// Illustration of Promise.allSettled()
// Method in Javascript with Example

const p1 = Promise.resolve(50);
const p2 = new Promise((resolve, reject) =>
setTimeout(reject, 100, 'geek'));
const prm = [p1, p2];

Promise.allSettled(prm)
.then((results) => results.forEach((result) =>
console.log(result.status,result.value)));

Output:

"fulfilled"
50
"rejected"
undefined

The complete list of JavaScript Promise is listed below:

JavaScript Promise Constructor: In JavaScript, a constructor gets called when an object is created using the new keyword.

Constructor Description Promise Handle asynchronous operations in JavaScript.

JavaScript Promise Properties: A JavaScript property is a member of an object that associates a key with a value.

Instance Properties Description constructor Return the promise constructor function for the object.

JavaScript Promise Methods: JavaScript methods are actions that can be performed on objects.

Static Methods Description all() Handle all the asynchronous operations), that take an array of promises(an iterable) as input. allSettled() Get a promise when all inputs are settled that is either fulfilled or rejected. any() Return a single promise that fulfills with the value from that promise. race() Returns a single Promise after receiving an iterable of promises as input. reject() Returns a Promise object that is rejected with a given reason. resolve() Returns a Promise object that is resolved with a given value. Instance Methods Description catch() The return value of the callback if it is called. then() Deal with asynchronous tasks such as API calls. finally() Return a Promise when a Promise is settled, that is, it is either fulfilled or rejected.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4