promises any

    0

    0

    My JavaScript recipes

    Take the first promise that resolves

    const promise1 = new Promise((resolve) => setTimeout(resolve, 100, 'quick'));
    const promise2 = new Promise((resolve) => setTimeout(resolve, 500, 'slow'));
    const promises = [promise1, promise2];
    Promise.any(promises).then((value) => console.log(value));
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.