Proxy Pattern: Techniques for Implementing Proxies (I)

Learn how to create a proxy object using composition object literals.

A proxy is an object that controls access to another object, called the subject. The proxy and the subject have an identical interface, and this allows us to swap one for the other transparently; in fact, the alternative name for this pattern is surrogate.

A proxy intercepts all or some of the operations that are meant to be executed on the subject, augmenting or complementing their behavior. The following illustration shows a schematic representation of this pattern:

Get hands-on with 1200+ tech skills courses.