jQuery type() Method

Beginner
6 min read
Updated: Oct 2026
4 examples
Live preview

What Is type()?

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.

Remember
$.type(value)  → lowercase type string

$.type(null)         → "null"
$.type([])           → "array"
$.type(new Date())   → "date"
$.type(/test/)       → "regexp"

typeof null          → "object"   // surprise!
typeof []            → "object"   // surprise!
NeedUse
Full type name (legacy)$.type(value)
Is it an array?$.isArray(value) or Array.isArray
Is it a function?$.isFunction(value)
Plain object?$.isPlainObject(value)

How to Use type()

Pass any value, read the type string, then branch.

  1. Start with a value whose kind you need to know.
  2. Call $.type(value) to get a lowercase string.
  3. Compare with === "array", === "null", and so on.
  4. In new code, prefer native checks instead of $.type.
PieceRequired?Role
objUsualValue to classify (omit → "undefined")
Return—Lowercase type string
Fallback—Unknown objects become "object"

Pseudocode

Pseudocode
function type(obj):
    if obj is undefined: return "undefined"
    if obj is null:      return "null"
    // use internal [[Class]] for built-ins
    return className.toLowerCase()   // "array", "date", ...

// Typical flow:
kind = $.type(input)
if kind === "array":
    loop items
else if kind === "null":
    handle missing value

Cheat Sheet

Keep these facts handy while classifying values with jQuery.

TopicDetail
SyntaxjQuery.type(obj) / $.type(obj)
SincejQuery 1.4.3
StatusDeprecated 3.3 · removed 4.0
Fixesnull, arrays, dates, regexps vs typeof
Array helper$.isArray()
Native array checkArray.isArray()
Modern general checkObject.prototype.toString.call(x)

Live Preview

Pick a sample value, run $.type, and compare with typeof.

Browser demo of $.type() — same ideas as the examples below.

Result
sample = null
$.type → "null"
typeof → "object"

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

Example 1 — Common Return Values

Official-style checks for the types you meet every day.

jQuery
console.log($.type(undefined));  // "undefined"
console.log($.type(null));       // "null"
console.log($.type(true));       // "boolean"
console.log($.type(3));          // "number"
console.log($.type("test"));     // "string"
console.log($.type([]));         // "array"
console.log($.type({}));         // "object"
Try It Yourself

How It Works

  1. Pass a value. Each call classifies one argument.
  2. Lowercase labels. Results are always lowercase strings.
  3. Built-ins. Arrays and plain objects get different names.
  4. Branch. Compare with === "string" (or another label) in real code.

Example 2 — null vs typeof

The main reason people reached for $.type.

jQuery
console.log(typeof null);   // "object"
console.log($.type(null));  // "null"
Try It Yourself

How It Works

  1. typeof quirk. In JavaScript, typeof null has always been "object".
  2. $.type. jQuery inspects the value and returns the accurate "null".
  3. Why it matters. Missing API fields and empty results are often null.
  4. Modern. Use value === null when that is all you need.

Example 3 — Array vs Array-Like Object

True arrays are "array"; plain objects with indexes are not.

jQuery
var list = ["a", "b", "c"];
var map = { 0: "a", 1: "b", length: 2 };

console.log($.type(list));  // "array"
console.log($.type(map));   // "object"
Try It Yourself

How It Works

  1. Real array. [] has the array [[Class]], so the result is "array".
  2. Array-like object. Numeric keys + length do not make a true array.
  3. Label. That object is still "object".
  4. Helper. For a boolean only, prefer $.isArray / Array.isArray.

Example 4 — Date and RegExp

typeof cannot name these; $.type can.

jQuery
var when = new Date();
var pattern = /^\d+$/;

console.log($.type(when));     // "date"
console.log($.type(pattern));  // "regexp"
console.log(typeof when);      // "object"
Try It Yourself

How It Works

  1. Built-ins. Date and RegExp are objects with distinct [[Class]] tags.
  2. $.type. Those tags become "date" and "regexp".
  3. typeof. Both look like plain "object".
  4. Modern. Use value instanceof Date or value instanceof RegExp when that is enough.

Edge Cases & Pitfalls

Check these before relying on type strings in real apps.

deprecated

Removed in jQuery 4.0

Do not start new features on $.type. Prefer native checks so upgrades stay smooth.

no args

$.type() means undefined

Calling with no argument returns "undefined" — same as passing undefined.

wrappers

Boxed primitives still match

new String("test") is "string", new Number(3) is "number" — same labels as primitives.

jquery

jQuery collections are "object"

$.type($("div")) does not say "jquery". Check for a jQuery object another way if you need that.

Browser Support

jQuery.type() existed in jQuery 1.4.3–3.x, was deprecated in 3.3, and removed in 4.0. Prefer native checks in all modern browsers. This page focuses on browser use with jQuery loaded.

✓ Deprecated · jQuery 3.3

jQuery.type()

Available with jQuery 1.4.3–3.x in Chrome, Firefox, Safari, and Edge. Prefer Array.isArray / typeof / toString.call for new code. Not present in jQuery 4.0.

Legacy Prefer natives
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
$.type() Legacy

Bottom line: Learn $.type() for legacy jQuery code. Write native type checks in new projects and before upgrading to jQuery 4.

Performance Notes

ApproachCostBest for
typeof x / x === nullCheapestPrimitives and null checks
Array.isArray(x)Very cheapArray detection in new code
$.type(x)Small helper costLegacy jQuery branching only

Type checks are cheap next to DOM work. Prefer the narrowest native test for your case instead of always asking for a full type string.

Key Takeaways

  • Role: $.type(value) → lowercase [[Class]] string.
  • Wins: accurate null, array, date, regexp.
  • Modern: prefer native checks over $.type.
  • Status: deprecated in 3.3, removed in 4.0.

One line: know $.type for legacy jQuery branching, but classify values with native checks in every new project.

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).

Next: isArray()

Learn the dedicated boolean helper for array detection in jQuery.

isArray tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful