How to access the target (which is myArray
) of myProxy
here?
function createProxy() { const myArray = [Math.random(), Math.random()]; return new Proxy(myArray, {}); } const myProxy = createProxy();
I've tried many ways. Was googled many blog posts, but found no way to get the target :(
You can make a copy of the data returned by the proxy using Object.assign()
:
const target_copy = Object.assign({}, my_proxy);
This will work for all enumerable own properties existing on the proxy/target.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With