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

132
Views
un ejemplo de async/await en javascript

Estoy estudiando async y await en javascript, y estoy un poco confundido sobre el orden de ejecución de la siguiente función que escribí cuando juego con async and await:

 const promiseA = new Promise((resolutionFunc, rejectionFunc) => { setTimeout(() => resolutionFunc(666), 5000); }); const test = async () => { await promiseA.then((val) => console.log("asynchronous logging has val:", val) ); }; const testTwo = () => { test(); console.log("immediate logging"); }; testTwo();

entiendo que en la función <testTwo()>, <test()> se ejecuta primero, se ha llamado y ejecutado, <test()> es una función asíncrona, y he puesto la espera delante de la promesa.

por qué este console.log("immediate logging"); ¿La línea de código se ejecuta primero?

por otro lado, si escribiera <testTwo()> como sigue:

 const testTwo = async () => { await test(); console.log("immediate logging"); };

todo esta bien

about 4 years ago · Juan Pablo Isaza
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!