How do I call toString on a JS Proxy js object, not the proxy object itself

Issue

I have a js Proxy object pointing to a jQuery object in javascript, this particular object has its own toString method natively defined. How do I call this? Assuming my Proxy is called _context then this

_context.toString();

returns the string from the toString() on the Proxy object, not the result of the toString() on the target object itself. Is it possible to pass this through?

Solution

_context.toString() will call on js side String(_contextJs) which is almost equivalent to _contextJs.toString() (except that null and undefined are handled). If this Js call throws an exception the default Object.toString is called. See the code on JsObject.toString.

Answered By – Alexandre Ardhuin

Answer Checked By – David Goodson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *