From the course: JavaScript: Async

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Defining asynchronous programming

Defining asynchronous programming - JavaScript Tutorial

From the course: JavaScript: Async

Defining asynchronous programming

- [Instructor] We can build program flow in JavaScript in two different ways. Synchronously and asynchronously. Using synchronous program flow, code is executed in the order it appears in your JavaScript files. So here, lines one through five of the code are executed first followed by lines six through 10 and then lines 11 through 15 are executed next, matching the order of statements in the code as written. In synchronous program flow, the browser parses and executes only one statement at a time. This results in our statements being executed in order. Synchronous program flow exhibits a behavior known as blocking, meaning that later statements are prevented from executing until earlier statements are finished. In many cases, this is what we want. For instance, a value needs to be calculated first before it can be used. But if an earlier statement may take awhile to execute and statements that follow don't rely on that…

Contents