How it executes.
WHAT SINGLE-THREADED MEANS
One thing executes at a time.
WHY THAT MATTERS
Blocking that thread freezes everything, including the interface in a browser.
WHAT THE EVENT LOOP DOES
Takes completed work from queues and runs the associated code, when the thread is free.
WHAT THAT ENABLES
Handling many operations without blocking, despite one thread.
WHAT ASYNCHRONOUS CODE IS FOR
Anything waiting: network, files, timers.
WHAT IT IS NOT FOR
Heavy computation, which still blocks.
WHAT TO USE FOR COMPUTATION
Workers, which run on separate threads.
WHAT PROMISES REPRESENT
A result arriving later.
WHAT THE MODERN SYNTAX PROVIDES
Asynchronous code that reads sequentially.
WHAT TO ALWAYS HANDLE
Failure.
WHY
Unhandled failures leave the program in an unknown state, and in some environments terminate it.
WHAT TO UNDERSTAND ABOUT ORDERING
Code after an asynchronous call runs before the result arrives.
WHAT THAT CAUSES
Values read before they are set, which is the commonest confusion for newcomers.