Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome javascript Proxy object is not defined

I wanted to experiment with the Proxy object that was introduced in EMCAScript 6, as described in this blogpost: http://ariya.ofilabs.com/2013/07/es6-and-proxy.html

However when I wanted to run the example code:

var engineer = { name: 'Joe Sixpack', salary: 50 };

var interceptor = {
  set: function (receiver, property, value) {
    console.log(property, 'is changed to', value);
    receiver[property] = value;
  }
};

engineer = Proxy(engineer, interceptor);

I got the error that Proxy is not defined. Does anybody know more about the support for proxies in Chrome? I am using Chrome version 33.0.1750.152 on a Mac.

like image 702
JasperTack Avatar asked Apr 11 '14 13:04

JasperTack


People also ask

What is JavaScript proxy object?

In JavaScript, proxies (proxy object) are used to wrap an object and redefine various operations into the object such as reading, insertion, validation, etc. Proxy allows you to add custom behavior to an object or a function.

What is ES6 proxy?

ES6 proxies sit between your code and an object. A proxy allows you to perform meta-programming operations such as intercepting a call to inspect or change an object's property. The following terminology is used in relation to ES6 proxies: target. The original object the proxy will virtualize.

What is proxy object?

A proxy object acts as an intermediary between the client and an accessible object. The purpose of the proxy object is to monitor the life span of the accessible object and to forward calls to the accessible object only if it is not destroyed.

Can I use proxy object?

The Proxy object allows you to create an object that can be used in place of the original object, but which may redefine fundamental Object operations like getting, setting, and defining properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs, and so on.


1 Answers

if you’re using Chrome most of the ES6 features are hidden behind a feature toggle. Browse to chrome://flags, find the section titled “Enable Experimental JavaScript” and enable it to turn on support: chrome://flags/#enable-javascript-harmony

After activation, restart your chrome browser and it should work

like image 52
radia Avatar answered Oct 07 '22 17:10

radia