Open this example in the interactive library
Source code
console.log(
await Promise.race([
Promise.resolve("first"),
Promise.resolve("second"),
]),
);
Sample output
first

Race completed tasks. A self-contained example using the JavaScript runtime.
Open this example in the interactive library
console.log(
await Promise.race([
Promise.resolve("first"),
Promise.resolve("second"),
]),
);
first