From the author

Sorry, couldn't resist a classic meme:

Now with all seriousness. We hear you asking "Do I even need to learn basic callbacks once there are Promises, Async-Await, Observables and newer stuff like that in JavaScript?! Aren't they just, you know, outdated?"

Let us clarify a few things. Take Promises, for example. You can see them as a set of async helpers that cover most everyday cases. Once a month you may get a special one where errors have to be handled differently, requests have to be arranged unusually, etc. Which will paralize you. You'll spend hours searching StackOverflow, asking random people for instant help, feeling humiliated. Or otherwise, in case you managed to finish this tutorial, you'll spend 10 minutes, writing your own special helper, without even seeing "the problem".

Second argument is that many popular libaries are callback based: Express, Passport, even some newer products use them intentionally as the "lowest common denominator" of async programming. So yes, callbacks are very relevant and will probably remain such, until the end of JavaScript (a long time ahead).

In this tutorial we deliberately decided to avoid "real" APIs like Node's FS or Browser's Fetch in favor of "abstract" setTimeout / setInterval -based code. There are three decisive reasons for this.

1. The best learning model is to learn "one thing at a time". Learning an API and learning its underlying concepts are two different tasks. Learning how to combine those concepts together and apply them to solve a real-world problem is a third task.

2. Real APIs are almost always saturated with extra "noise". For example, fetch will require you to always apply two promise calls in a row, so you may take it as a norm (which it isn't). FS.readFile will require you to learn buffers, to think about filesystem specifics. Again, basically, you have to switch from the original intent of "learning some async" to learning stuff that slows you down and may even be irrelevant (assuming so many possible JS application fields).

3. Timeouts and intervals aren't only extremely important on themselves, they are perfect as stubs for actual file, db, network, whatever "real" APIs. You'll also find them absolutely indispensable in tests, library code and many other key places. You can't overpractise them.

To summarize, we believe that solid knowledge of async patterns should be built upon abstractions (i.e. ideas) rather than copy-paste driven "realistic" snippets. You'll have zero problems with understanding such snippets and real-world JavaScript APIs, once you get the principles.

Tools

Shell / Terminal. Windows 10 has bash shell.

Latest NodeJS

Editor (Atom, VSCode, Webstorm...)

Theory