Is there a way to call toPrimitive in Javascript?
Is there a way to call toPrimitive on a value in Javascript? Why? I'm using Proxy in my project. function makeProxy(unknown_value) { let proxy_target = ()=>{}; proxy_target.inner = unknown_value; proxy_target.my_data = 123456; return new Proxy(proxy_target, some_proxy_handler); } let proxied_value = makeProxy(<? something unknown ?>); This proxy redirects all the calls to "inner". And eventually I was stroke by something like this: console.log(1+proxied_value); Here Javascript calls (1) proxied_value.get(proxy_target, Symbol.toPrimitive) Because Javascript wants to try to convert proxied_value
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.