Understanding Asynchronous JavaScript
Pyyhkäise näyttääksesi valikon
JavaScript does not always execute code step by step from top to bottom.
Some operations take time, such as reading data, making requests, or waiting for a response. JavaScript handles these operations asynchronously, which means it does not block the rest of the code while waiting.
console.log("Start");
setTimeout(() => {
console.log("Done");
}, 1000);
console.log("End");
Even though the timeout is written in the middle, the output will be:
Start
End
Done
This happens because the delayed operation runs later, while the rest of the code continues immediately.
This behavior is important in backend development because many tasks involve waiting, such as database queries or API calls.
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 1. Luku 13
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Osio 1. Luku 13