Closed web-bert closed 9 years ago
Is Host "Object Property". Meaning the host object property references an object.
Sorry for any confusion.
Ah I see!
Is it worth adding something like isObjectProperty, or leave apps to use typeof to check themselves?
On 22 Apr 2014, at 19:03, David Mark notifications@github.com wrote:
Is Host "Object Property". Meaning the host object property references an object.
Sorry for any confusion.
— Reply to this email directly or view it on GitHub.
Use typeof where there is no ambiguity (e.g. booleans, strings, etc.) The isHost* functions are for host object properties that reference objects, which are known to vary their typeof result. isHostMethod specifically looks for host methods (which can be safely called), whereas isHostObjectProperty allows any sort of object (which can be referenced in any way), excluding ActiveX methods (which can only be safely called). The one used depends on what your code will do with the object. Choosing the wrong one can blow up (which makes it odd that copycat libraries merge these two into one).
I wanted to add a new function to check if the user is online, and this is the code I was going to do:
but isHostObjectProperty returns false because the typeof check returns "boolean". Therefore should this function be renamed to:
As that shows what it actually does? It would be nice to then change isHostObjectProperty to just check for the existence of a property on an object (as that is what I would expect it to so), then it can be re-used by app code?