Last active
October 6, 2018 05:40
-
-
Save danielb2/7a4fe9ea27a44ed3a38e8d34a6301d54 to your computer and use it in GitHub Desktop.
proxy play
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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