Skip to content Skip to sidebar Skip to footer

Understanding Es6 Javascript Proxies

I'm trying to register function change via proxies with this code: const handler = { construct(objTarget, args, oldConstructor) { return new objTarget(...args) }, set(ta

Solution 1:

Notice the handler.construct() is simply

returnnewobjTarget(...args)

There's nothing special about the returned value, it's just an instance of the proxy's target wand so something like

returnnewProxy(newobjTarget(...args), someHandler)

would allow you to intercept operations on w based on the traps defined in someHandler.

Post a Comment for "Understanding Es6 Javascript Proxies"