CHAPTER 9The Composite Pattern

The composite is a design pattern that is tailor-made for creating dynamic user interfaces on the Web. Using this pattern, you can initiate complex or recursive behaviors on many objects with a single command. This allows your glue code to be simpler and easier to maintain, while delegating the complex behaviors to the objects.

The composite provides two benefits for you, the overworked JavaScript programmer:

  1. It allows you to treat a collection of objects the same as you would treat any of the particular sub-objects. A composite implements the same operations as its constituent objects. Executing one of these operations on the composite passes it down to all of its children. Each one then executes the same operation. ...

Get Pro JavaScript™ Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.