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
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
Finally, you can use a host object as the prototype of a wrapper to which you can add whatever you need.
Good luck!
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!