What is a proxy in JavaScript, why is it useful?
From what I've read, a proxy is just an object that "wraps" another object and do things on its own and decide whether or now to use the initial object. But this is still vague in my mind it's not clicking, proxies are just like proxies in general, like when someone does an action on your behalf, right? Here, why is it useful, what kind of things can we do with it please.
2 Replies
If you want a concrete example, that's how Vue and svelte implement their reactivity systems. It allows them to track and monitor the reads and writes of properties on objects.
In general it is used by libraries and frameworks to hide their logic from the client code by providing and requiring objects that look like normal ones but actually have non-native behaviors tied to them.
yeah I'm learning vue and I noticed that they mention proxies in their docs, that why I was wondering what it was