Composite

A tree structure of simple and composite objects.

  • Composite pattern allows you to have a tree structure and ask each node in a tree structure to perform a task.

  • creates a tree structure of group of object.

  • It is used where we need to treat a group of objects in similar way as a single object.

  • composes objects in in term of tree structure to represent part-hole hierarchy.

  • This tree is constructed with leaf (no children - represents leaf) and composite (has collection of child components - represents branch).

  • Most frequently used in JavaScript.

Last updated