jQuery 1.4 源码 449 行(core.js 431 行),判断是否为函数的方法如下(思路来源于 Douglas Crockford 的《The Miller Device》):
<code><span class="pln">isFunction</span><span class="pun"><font color="#666600">:</font></span><span class="pln"> </span><span class="kwd"><font color="#000088">function</font></span><span class="pun"><font color="#666600">(</font></span><span class="pln"> obj </span><span class="pun"><font color="#666600">)</font></span><span class="pln"> </span><span class="pun"><font color="#666600">{</font></span><span class="pln"><br> </span><span class="kwd"><font color="#000088">return</font></span><span class="pln"> </span><span class="kwd"><font color="#000088">toString</font></span><span class="pun"><font color="#666600">.</font></span><span class="pln">call</span><span class="pun"><font color="#666600">(</font></span><span class="pln">obj</span><span class="pun"><font color="#666600">)</font></span><span class="pln"> </span><span class="pun"><font color="#666600">===</font></span><span class="pln"> </span><span class="str"><font color="#008800">"[object Function]"</font></span><span class="pun"><font color="#666600">;</font></span><span class="pln"><br></span><span class="pun"><font color="#666600">},</font></span></code>
同时 jQuery 的作者也作了部分注释:
See test/unit/core.js for details concerning isFunction. Since version 1.3, DOM methods and functions like alert aren't supported. They return false on IE (#2968).
即:此方法在 IE 下无法正确识别 DOM 方法和一些函数(例如 alert 方法等)。
为什么会这样呢?