O'Reilly logo

Pro JavaScript™ Design Patterns by Dustin Diaz, Ross Harmes

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 6Chaining

In this chapter we look at JavaScript's ability to chain methods together. By using a few simple techniques, application developers can streamline their code authoring. As well as writing time-saving functions that reduce the burden of common tasks, you can improve how code is implemented. In the end, you can write an entire JavaScript library that embraces the technique of chaining, and chains together all your favorite methods.

Chaining is really just a syntax hack. It allows you to express complex operations in a small amount of code by reusing an initial operation. Chaining requires two parts: a factory that creates an object around an HTML element (we cover factories in depth in Chapter 7), and methods that perform some ...

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