Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 1.89 KB

asynchronous.md

File metadata and controls

20 lines (15 loc) · 1.89 KB

Asynchronous code

JavaScript is a single-threaded programming language. Considering this it is very important that you understand the behavior of asynchronous code. There are three important techniques for writing asynchronous code in JavaScript:

  • Callbacks
  • Promises
  • Async / Await

Resources

For understanding asynchronous JavaScript in general read Understanding Asynchronous JavaScript .

Callbacks

A callback is a function that is to be executed after another function has finished executing. Read JavaScript: What the heck is a Callback?.

Promises

For understanding promises read A Simple Guide to ES6 Promises. For more information about promises and good practices read Master the JavaScript Interview: What is a Promise?. It is important that you know the prototype methods .then, .catch and the functions available from Promise: Promise.all and Promise.race.

Async / Await

The article How to escape async/await hell points out the correct usage of async/await and how you can avoid common pitfalls.