Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

70
Views
Múltiples funciones de espera asíncrona solo activaron la última

 const fun = (x) => { console.log(`Meth... ${x}`); setTimeout(() => { onReceive(`Fun Received: ${x}`); }, 100); return x; } const publish = () => { return new Promise(resolve => { window.onReceive = (token) => { resolve(token); } }); } const Inst = () => { const getAs = async(x) => { console.log(`Getting As ----- ${x}`); const res = await publish(fun(x)); console.log(`Res is '${res}' ---- ${x}`); } return { getAs, } } const inst = Object.freeze(Inst()); const a = async() => { await inst.getAs(1); await inst.getAs(2); await inst.getAs(3); await inst.getAs(4); await inst.getAs(5); }; a(); const b = async() => { await inst.getAs(4); await inst.getAs(5); await inst.getAs(6); await inst.getAs(7); }; b(); // Comment or remove `b()` to see the different result in Console


Me confundí por qué la función solo llamó a la última async await ( b() del ejemplo) . ¿Por qué dentro de a() parece que no se llamó en absoluto?

Si comento / elimino b() , todo el interior de a() recibirá una llamada.

Necesito ayuda/explicación para resolver tal problema 🙏.

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!