Pergunta de entrevista da empresa CERN

What is the difference between await/async and .then() in javascript?

Resposta da entrevista

Sigiloso

10 de set. de 2025

They are functionally similar (both work with promises), but await will wait for the promise to produce a result before continuing to the next statement. .then() accepts a callback instead. await/async tends to produce more readable code, but cannot always be used if you e.g. want to run two series of events at the same time.