Asynchronous Code

noun

say it: “ay-SING-kruh-nus kohd” /eɪˈsɪŋkrənəs koʊd/ or “AY-sink KOHD” /ˈeɪsɪŋk koʊd/

Code that starts a slow job, such as a timer or a download, lets the rest of the program carry on, and finishes the job later.

What is Asynchronous Code in JavaScript?

Asynchronous Code — Code that starts something that takes time, such as a timer or a download, and carries on without waiting; the rest of the job runs later, when the result is ready. It's how a page keeps working while it waits.

console.log('Order taken');
setTimeout(() => console.log('Pizza ready'), 1000);
console.log('Next customer');
// Order taken
// Next customer
// Pizza ready

In a sentence

  • “Because the timer was asynchronous, Next customer printed before Pizza ready.”
  • “The weather download is asynchronous code, so the rest of the page kept working while it waited.”
  • “Thanks to asynchronous code, the playlist page stays scrollable while the song list downloads.”
  • “The pizza tracker uses asynchronous code to wait for the oven without freezing the order screen.”

Level: Apprentice · More JavaScript terms at this level

Updated