Sascha Schulz
2023-08-01 c88a9176977fc392c8fddca2e4b68389cb1bef04
add promise race example
1 Dateien hinzugefügt
7 ■■■■■ Geänderte Dateien
templates/007-js/async/race.js 7 ●●●●● Patch | Ansicht | Raw | Blame | Historie
templates/007-js/async/race.js
Neue Datei
@@ -0,0 +1,7 @@
const contestants = [
    new Promise((r) => setTimeout(() => r("a"), 1000)),
    new Promise((r) => setTimeout(() => r("b"), 1000)),
    new Promise((r) => setTimeout(() => r("c"), 1000))
];
(async () => console.log(await Promise.race(contestants)))();