Hi I was wondering if anyone knew how to get an array out of a proxy's target value in JavaScript. I have something like this :
Proxy : [[target]] : Array // the array I need to extract [[handler]] : Object [[IsRevoked]] : false
Hi I was wondering if anyone knew how to get an array out of a proxy's target value in JavaScript. I have something like this :
Proxy : [[target]] : Array // the array I need to extract [[handler]] : Object [[IsRevoked]] : false
 
    
     
    
    Just take that original object and parse it to and from JSON and get yourself a clean object!
item = JSON.parse(JSON.stringify(item))
 
    
    If all you have is a reference to the proxy, there is no way (by default) for you to get the proxy's target. A specific proxy could provide a way (via one of its trap handlers, probably), but there is none by default.
 
    
    As an addition, you may get a copy of the target by spreading if the handler maps everything accordingly. But you can not get the original [[target]] object.
const proxy = new Proxy([1, 2, 3], {
  get(target, prop, receiver) {
    return target[prop];
  }
});
console.log([...proxy]);