6.1
Synchronous code
Examples with a Run button are editable. Underlined terms open a short definition.
SYNCHRONOUS CODE
const p = document.querySelecter('.p');
p.textContent = 'My name is Jonas!';
alert('Text set!'); // Block the all code from running untill
// you close the popup
p.style.color = 'red';
- 👉 Most code is synchronous;
- 👉 Synchronous code is executed line by line;
- 👉 Each line of code waits for previous line to finish;
- 👎 Long-running operations block code execution.
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.