JS: Proxy

By Xah Lee. Date: . Last updated: .

2016-11-08 this page is work in progress

New in JS2015.

proxy is like a wrapper to js objects. It lets you change the behavior of things that act on a object.

Proxy object is used to

create new proxy like this:

var = new Proxy(target , handler)
// object
var tt = {x:3};

// we want to change the behavior of accessing properties of tt

// the β€œhandler”
var hh = {
   get: function(tt, propertyName, receiver) {
       return 99;

// create proxy object.
var pr = new Proxy ( tt, hh );
// this will target tt, with handler hh

// access a property
console.log (pr.x); // prints 99

console.log (pr.y); // prints 99

ECMAScript 2015 Β§Reflection#sec-proxy-constructor

BUY Ξ£JS JavaScript in Depth