I'm exploring Proxies in JavaScript, and I want to know if there are any ways to Proxy
primitives. If I try to do so:
new Proxy('I am a string');
It throws Uncaught TypeError: `target` argument of Proxy must be an object, got the string "I am a string"
The reason I want to do this is to be able to proxy the primitive's prototype methods. I could edit the prototype, but editing every single prototype function of every single primitive does not sound viable.
new Proxy(new String("I am a string"))
. However, I suspect that might be an XY problem. What exactly do you want to do that requires proxying the methods? – Pro