R
RobG
<FAQENTRY>
There has been frequent mention of the legendary "isHostMethod"
function in this group over the last 18 months or so in conjunction
with statements that "boolean type conversion is out" for testing host
method availability. While that may be so, trying to find the elusive
method in all the noise is pretty difficult.
I discovered this version posted by Thomas in February 2008[1]:
function isHostMethod(o, m)
{
var t = typeof o[m];
return (/^(function|object)$/.test(t) && o[m])
|| t == "unknown";
}
It is also difficult to find posts on why it is preferred to the more
common type converting tests. Perhaps it's time to add an FAQ entry
about testing host methods that briefly states why isHostMethod should
be used and includes the code (with appropriate attribution) so it can
be referenced and found more easily.
</FAQENTRY>
1. <URL: http://groups.google.com/group/comp.lang.javascript/msg/eceaf3fa529973ec
There has been frequent mention of the legendary "isHostMethod"
function in this group over the last 18 months or so in conjunction
with statements that "boolean type conversion is out" for testing host
method availability. While that may be so, trying to find the elusive
method in all the noise is pretty difficult.
I discovered this version posted by Thomas in February 2008[1]:
function isHostMethod(o, m)
{
var t = typeof o[m];
return (/^(function|object)$/.test(t) && o[m])
|| t == "unknown";
}
It is also difficult to find posts on why it is preferred to the more
common type converting tests. Perhaps it's time to add an FAQ entry
about testing host methods that briefly states why isHostMethod should
be used and includes the code (with appropriate attribution) so it can
be referenced and found more easily.
</FAQENTRY>
1. <URL: http://groups.google.com/group/comp.lang.javascript/msg/eceaf3fa529973ec