jQuery type() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Utilities

Definition

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.

jQuery
$.type(value)  → lowercase type string

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

typeof null          → "object"   // surprise!
typeof []            → "object"   // surprise!
CallWhat it does
type()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

ParameterDescription
Step 1Start with a value whose kind you need to know.
Step 2Call $.type(value) to get a lowercase string.
Step 3Compare with === "array", === "null", and so on.

Return Value

Return ValueDescription
BooleanOften true or false depending on the match or state.
Value / undefinedGetters 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.

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.

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.

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

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() Method

Learn the dedicated boolean helper for array detection in jQuery.

isArray() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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