Javascript - Proxies in ES6

Introduction

Proxy objects intercept any program's behavior.

They modify the operations of an object and implement custom behaviors.

A proxy object wraps the target object and modifies its behavior.

We can create a proxy using:

const proxy = new Proxy(target, handler); 
  • target is the object whose behaviors are being modified and
  • handler is an object whose properties are functions(traps), which are called when various operations are performed against the proxy.

Handler objects allow us to define the new behavior of the target object.

Related Topics