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

Sigfried picture Sigfried · Nov 1, 2018 · Viewed 9.4k times · Source

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!

Answer

Alex Park picture Alex Park · Jan 31, 2019

I find a hack. In my case, I can't control the creation of the proxy(mobx observable values). So the solution is:

JSON.parse(JSON.stringify(your.object))