11

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.

4 Answers 4

7

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

Sign up to request clarification or add additional context in comments.

2 Comments

This doesn't seem to work anymore in the latest version of Chrome.
v8 (the javascript engine behind Chrome) people implemented it and then removed it due to some security stuff. They are re-implementing it now.
2

V8 released full support for Proxy in 4.9

Source; http://v8project.blogspot.de/2016/01/v8-release-49.html

Chrome 49 uses V8 4.9

Comments

1

Just start chrome from command line with flag --js-flags="--harmony-proxies" or add it to chrome's shortcut

Comments

-1

There is a Chrome specific shim for Proxy available at https://github.com/anywhichway/chrome-proxy. If your needs are basic, this should get you by until the v8 team finishes re-implementation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.