Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The best way to test if an object is a function is <code>typeof myFunc === 'function'</code>. If you are using a library, use that library's function test: <code>jQuery.isFunction(myFunc)</code>.</p> <p>Things <em>can</em> be misreported as functions when using <code>typeof</code>. This is very rare but a library is there to remove these inconsistencies. jQuery working around these issues:</p> <ul> <li>Firefox reports function with <code>typeof document.createElement("object")</code></li> <li>Safari reports function with <code>typeof document.body.childNodes</code> </li> <li>Older versions of Firefox reported regular expressions as functions (this not the case in 3.0).</li> <li>Some IE built in global functions (<code>alert</code>) and some node methods (<code>getAttribute</code>) are reported to be of type "object".</li> </ul> <p>Using <code>instanceof</code> rather than <code>typeof</code> circumvents some of these. For example, <code>document.createElement("object") instanceof Function</code> is <code>false</code> in Firefox. </p> <p>You can view the birth of the first method in the comments for <a href="http://dev.jquery.com/ticket/2968" rel="nofollow noreferrer">the original ticket (#3618)</a>. The new method is from <a href="http://dev.jquery.com/changeset/5947" rel="nofollow noreferrer">changeset 5947</a> and seems to have been invented by Resig to solve <a href="http://dev.jquery.com/ticket/3618" rel="nofollow noreferrer">IE memory leaks</a>. It's probably slower, but smaller, and cleaner.</p> <p>There isn't much difference between == and === here in terms of how things work but the strict evaluation is ever so slightly faster and thus preferred.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload