jQuery.type(obj) (alias $.type) returns a lowercase string for the value’s internal JavaScript [[Class]] (added in jQuery 1.4.3). It is clearer than typeof for null, arrays, dates, and regexps.
Syntax
Start with these common calls. Keep them short and readable.
Learn jQuery.type(): get accurate type strings for null, arrays, dates, and regexps, compare with typeof, migrate away from deprecated $.type, examples, pitfalls, and FAQs.
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Start with a value whose kind you need to know.
Step 2
Call $.type(value) to get a lowercase string.
Step 3
Compare with === "array", === "null", and so on.
Return Value
Return Value
Description
Boolean
Often true or false depending on the match or state.
Value / undefined
Getters usually return a value from the first matched element, or undefined when nothing applies.
jQuery Examples
Example 1 — Common Return Values
Official-style checks for the types you meet every day.
Real array.[] has the array [[Class]], so the result is "array".
Array-like object. Numeric keys + length do not make a true array.
Label. That object is still "object".
Frequently Asked Questions
jQuery.type(obj) returns a lowercase string for the value’s internal JavaScript [[Class]] — such as "null", "array", "date", "regexp", "string", or "object". It fixes common typeof surprises.
typeof null is "object" and typeof [] is "object". $.type(null) is "null" and $.type([]) is "array". $.type also returns "date" and "regexp", which typeof cannot name.
Common values include undefined, null, boolean, number, string, function, array, date, regexp, error, symbol, and object. Anything else that is an object usually falls through to "object".
jQuery.isArray(obj) is effectively $.type(obj) === "array". Use isArray for a boolean; use type when you need the full type name for branching.
Not for new code. It was deprecated in jQuery 3.3 and removed in 4.0. Prefer Array.isArray, typeof for primitives, and Object.prototype.toString.call for richer checks.
Calling $.type() with no value returns "undefined" — same as $.type(undefined).