Tuesday 15 August 2023

How to test if an object is a Proxy?

I would like to test if a JavaScript object is a Proxy. The trivial approach

if (obj instanceof Proxy) ...

doesn't work here, nor does traversing the prototype chain for Proxy.prototype, since all relevant operations are effectively backed by the underlying target.

Is it possible to test if an arbitrary object is a Proxy?



from How to test if an object is a Proxy?

No comments:

Post a Comment