Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: typeof operator on a .NET method returns "object" - is that correct?

$
0
0
Hi danielearwicker,

What you're seeing is correct. Host objects can't masquerade as JavaScript functions.

For JSON there are several possibilities. For example, you could add a custom toJSON() method to your JavaScript array. You could also pass a replacer function to JSON.stringify().

In theory it's also possible for a host object to expose a property whose value is a script function, although that doesn't seem to work for toJSON() in V8; apparently it checks more than just the typeof string.

Finally, you can use a host object as the prototype of a wrapper to which you can add whatever you need.

Good luck!

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>