JS: Proxy (ES2015)

By Xah Lee. Date: . Last updated: .

2016-11-08 this page is work in progress

New in ES2015.

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

creat 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

Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS Basics
  4. JS in Depth
  5. JS Reference
  6. DOM
  7. SVG
  8. JS Misc
  9. Web Dev Blog