References

Promise.any()

Leírás

A metódus egy iterált ígéretét adja vissza.

Szintaxis

Promise.any(iterable)

Példa

const promise1 = Promise.reject(0)
const promise2 = new Promise((resolve) => setTimeout(resolve, 100, 'quick'))
const promise3 = new Promise((resolve) => setTimeout(resolve, 500, 'slow'))
 
const promises = [promise1, promise2, promise3]
 
Promise.any(promises).then((value) => console.log(value))
 
// Expected output: "quick"
in this article
back to top