O'Reilly logo

Beginning Node.js by Basarat Ali Syed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 10

image

Simplifying Callbacks

The evented/asynchronous nature of Node.js means that it is possible to end up with deeply nested callbacks. There are various strategies in JavaScript that help reduce the callback nesting. In this chapter, we will explore these patterns. These help maintain readability, but more importantly these strategies will help decrease the likelihood of bugs creeping up on you. I promise.

The Callback Hell

Note that as we explore this section, it might seem like the situation is dire. Don’t worry. When we look at promises in the next section, you will find the pot of gold at the end of the rainbow.

An obvious issue with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required