Behavioral patterns deal with the assignment of responsibilities between objects and the algorithms used to achieve communication.
- Chain of Responsibility: Decouples the sender of a request from its receivers by giving multiple objects a chance to handle the request.
- Command: Encapsulates a request as an object, allowing for parameterization, queuing, logging, and undoable operations.
- Interpreter: Defines a representation for the grammar of a language and an interpreter to deal with this grammar.
- Iterator: Provides a way to access elements of a collection sequentially without exposing its underlying representation (e.g., ES6 Iterator).
- Mediator: Defines an object that encapsulates how a set of objects interact.
- Memento: Captures and externalizes an object's internal state so the object can be restored to this state later without violating encapsulation.
- Observer: Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically (e.g., MutationObserver, IntersectionObserver).
- State: Allows an object to alter its behavior when its internal state changes, appearing as if the object changed its class.
- Strategy: Defines a family of algorithms, encapsulates each one, and makes them interchangeable.
- Template Method: Defines the skeleton of an algorithm in a method, deferring some steps to subclasses.
- Visitor: Represents an operation to be performed on the elements of an object structure, allowing new operations to be defined without changing the classes of the elements on which it operates.