JavaScript: 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

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

JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS in Depth

Basic Syntax

Value Types

Variable

String

Function

Property

Object and Inheritance

Array

Constructor/Class

Iterable 🌟

Misc