Because it is trivial to pass around functions in JavaScript, asynchronous programming comes easy. However, it’s equally easy to write code that results in unpredictable execution order.
For example, it wouldn’t be that odd to see a method like this on some object:
With this method, the caller can’t be certain if the callback will be called before the return or after. Instead, this method should be written like this:
This makes for predictable code flow, which is particularly important when a callback changes some shared state.