Skip to content

Instantly share code, notes, and snippets.

@danielb2
Last active October 6, 2018 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielb2/7a4fe9ea27a44ed3a38e8d34a6301d54 to your computer and use it in GitHub Desktop.
Save danielb2/7a4fe9ea27a44ed3a38e8d34a6301d54 to your computer and use it in GitHub Desktop.
proxy play
class Foo {}
handler = {};
handler.construct = function (klass, args) {
console.log(`called constructor with ${JSON.stringify(args)}`);
return new klass(...args);
};
FooProxy = new Proxy(Foo, handler);
foo = new FooProxy('yoda'); // => called constructor with ["yoda"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment