Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

30 lines (30 sloc) 1.789 kb
<?xml version="1.0"?>
<entry type="method" name="jQuery.type" return="String">
<title>jQuery.type()</title>
<signature>
<added>1.4.3</added>
<argument name="obj" type="PlainObject">
<desc>Object to get the internal JavaScript [[Class]] of.</desc>
</argument>
</signature>
<desc>Determine the internal JavaScript [[Class]] of an object.</desc>
<longdesc>
<p>A number of techniques are used to determine the exact return value for an object. The [[Class]] is determined as follows:</p>
<ul>
<li>If the object is undefined or null, then "undefined" or "null" is returned accordingly.
<ul><li>jQuery.type(undefined) === "undefined"</li><li>jQuery.type() === "undefined"</li><li>jQuery.type(window.notDefined) === "undefined"</li><li>jQuery.type(null) === "null"</li></ul>
</li>
<li>If the object has an internal [[Class]] equivalent to one of the browser's built-in objects, the associated name is returned. (<a href="http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/">More details about this technique.</a>)
<ul><li>jQuery.type(true) === "boolean"</li><li>jQuery.type(3) === "number"</li><li>jQuery.type("test") === "string"</li><li>jQuery.type(function(){}) === "function"</li><li>jQuery.type([]) === "array"</li><li>jQuery.type(new Date()) === "date"</li><li>jQuery.type(/test/) === "regexp"</li></ul>
</li>
<li>Everything else returns "object" as its type.</li>
</ul>
</longdesc>
<example>
<desc>Find out if the parameter is a RegExp.</desc>
<code><![CDATA[$("b").append( "" + jQuery.type(/test/) );]]></code>
<html><![CDATA[Is it a RegExp? <b></b>]]></html>
</example>
<category slug="utilities"/>
<category slug="version/1.4.3"/>
</entry>
Jump to Line
Something went wrong with that request. Please try again.