Skip to guide content
[js] recap
Chapter 6 · Asynchronous JavaScript Asynchronous code

6.2

Asynchronous code

Examples with a Run button are editable. Underlined terms open a short definition.

ASYNCHRONOUS CODE

const p = document.querySelecter('.p');
setTimeout(() => {
    // ASYNCHRONOUS code NON-Blocking
    p.textContent = 'My name is Jonas!';
}, 5000);
p.style.color = 'red';
  • 👉 Asynchronous code is executed after a task that runs in the “background” finishes;
  • 👍 Asynchronous code is non-blocking;
  • 👉 Execution doesn’t wait for an asynchronous task to finish its work;
  • 👉 Callback functions alone do NOT make code asynchronous!

Your last opened chapter is saved in this browser when local storage is available.

Discuss this section

Questions, corrections or a better example? Comments use GitHub Discussions.