Register to get access to free programming courses with interactive exercises

About JS: Asynchronous programming

JavaScript is a language designed to run client-side. This has greatly affected not only the design of the language itself, but also the way its runtime environments are structured, with browsers, Node.js, and others. Browsers are designed for the so-called event-driven model, where code isn't executed continuously, but rather waits for user events, like button presses, mouse clicks, or scrolling. Each of these events (and dozens of others) triggers the necessary handler, and it has special requirements: it mustn't stop anything happening, because one event can cause many things to happen (almost in parallel), and the user must be able to continue to interact with the interface.

For these reasons, all engines (js-code executables) are built on an asynchronous model. Any input/output operations (such as Ajax requests) are performed asynchronously. Asynchronous code is wholly different from synchronous code, and takes time to get used to. It has a different way of handling errors and, in general, a different approach to writing code. Adding some features, creates problems in other places: what was easy to do in synchronous code may be difficult in asynchronous code. It's the price we pay for performance.

Asynchronous programming in JavaScript has gone through several stages: from collabs and promises, to the async/await concept. All of these approaches are important in their own way and will be discussed in this course. At the end, you'll learn how to write modern, efficient and understandable code that has the advantages of asynchronous code and is almost as good as synchronous code in terms of clarity and simplicity.

The main topics of this course are:

  • Asynchronous IO
  • Error handling
  • Event Loop
  • Timers
  • Promises
  • Async/Await
  • EventEmitter

Preparation

In this course, we study asynchrony, one of the most important things in JavaScript. To understand it, you need a good knowledge of basic programming language syntax, higher order functions, HTTP, and working with collections. These topics are covered in our other JavaScript courses. The correct sequence of courses can be found in the profession Frontend Programmer.


Hexlet Experts

Are there any more questions? Ask them in the Discussion section.

The Hexlet support team or other students will answer you.

About Hexlet learning process

For full access to the course you need a professional subscription.

A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.

Get access
130
courses
1000
exercises
2000+
hours of theory
3200
tests

Sign up

Programming courses for beginners and experienced developers. Start training for free

  • 130 courses, 2000+ hours of theory
  • 1000 practical tasks in a browser
  • 360 000 students
By sending this form, you agree to our Personal Policy and Service Conditions

Our graduates work in companies:

<span class="translation_missing" title="translation missing: en.web.courses.lessons.registration.bookmate">Bookmate</span>
<span class="translation_missing" title="translation missing: en.web.courses.lessons.registration.healthsamurai">Healthsamurai</span>
<span class="translation_missing" title="translation missing: en.web.courses.lessons.registration.dualboot">Dualboot</span>
<span class="translation_missing" title="translation missing: en.web.courses.lessons.registration.abbyy">Abbyy</span>
Suggested learning programs

From a novice to a developer. Get a job or your money back!

Frontend Developer icon
Profession
beginner
Development of front-end components for web applications
start anytime 10 months

Use Hexlet to the fullest extent!

  • Ask questions about the lesson
  • Test your knowledge in quizzes
  • Practice in your browser
  • Track your progress

Sign up or sign in

By sending this form, you agree to our Personal Policy and Service Conditions
Toto Image

Ask questions if you want to discuss a theory or an exercise. Hexlet Support Team and experienced community members can help find answers and solve a problem.