javascriptecmascript-6es6-proxy

how do I turn an ES6 Proxy back into a plain object (POJO)?


I'm using a library that turns things into ES6 Proxy objects, and another library that I think is choking because I'm passing it one of these (my code is a travesty, I know), and I couldn't figure out how to unProxy the Proxy object.

But I was just being dumb. Proxies can do anything!


Solution

  • For my use case (LWC), I used structuredClone. Creates a deep clone and doesn't require a library like lodash.

    structuredClone(proxyObj);