1. Promise.all(): it is used to handle multiple promises together. It takes an array of promises as input, and then it gives an array as output. syntax : const [data1, data2, data3]=Promise.all([p1, p2, p3]) 3s 1s 4s ===> it takes 4 seconds to fulfil the promise. all methods.

Example :

const p1 = new Promise((resolve, reject) => {
	setTimeout(() => {
		resolve("success...");
	}, 1000);
});
	
const p2 = new Promise((resolve, reject) => {
	setTimeout(() => {
		resolve("success...");
		// reject("fail...");
	}, 1000);
});

Promise.all([p1, p2]).then(([data, data2]) => console.log(data, data2)).catch((error)=>console.log(error));
//or
async function getData() {
	const [data, data2] = await Promise.all([p1, p2]);
}
getData();

Failure case of Promise.all method:

Example :

Promise.all([p1, p2])
.then(([data, data2]) => console.log(data, data2))
.catch((error)=>console.log(error));

promise.allSettled() :

Promise.race() :