jQuery isFunction() Method

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

What Is isFunction()?

jQuery.isFunction(value) (alias $.isFunction) returns true when value is callable as a function (since jQuery 1.2). Use it to guard optional callbacks before calling them.

Remember
$.isFunction(value)  → true | false

$.isFunction(function () {})  // true
$.isFunction("text")          // false
$.isFunction($)               // true  (jQuery factory)
$.isFunction($("div"))        // false (collection)

// Prefer in new code:
typeof x === "function"
NeedUse
Is it a function? (legacy)$.isFunction(x)
Is it a function? (modern)typeof x === "function"
Type string$.type(x)
No-op placeholder$.noop

How to Use isFunction()

Test first, then call — or migrate to native typeof.

  1. Have a value that might be a callback (plugin option, handler, done).
  2. Call $.isFunction(value) (legacy) or typeof value === "function" (preferred).
  3. If true, invoke it safely.
  4. If false, skip or use a fallback like $.noop.
PieceRequired?Role
valueYesAnything to test
Return—Boolean
Modern replacement—typeof x === "function"

Pseudocode

Pseudocode
function isFunction(value):
    return typeof value === "function"

// Typical callback guard:
if isFunction(done):
    done(result)
else:
    // skip or use noop

Cheat Sheet

Keep these facts handy while checking callables.

TopicDetail
SyntaxjQuery.isFunction(value) / $.isFunction(value)
SincejQuery 1.2
StatusDeprecated 3.3 · removed 4.0
True forFunctions, arrows, async, $
False forStrings, objects, jQuery collections
Prefertypeof x === "function"
Related$.type(x) === "function"

Live Preview

Test common values with $.isFunction and native typeof.

Browser demo of $.isFunction() vs typeof — same idea as the examples below.

Result
value = function () {}
$.isFunction(value) → true
typeof value === "function" → true

jQuery Examples

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

Example 1 — Official Function Test

A function is true; a string is false.

jQuery
console.log($.isFunction(function () {}));  // true
console.log($.isFunction("text"));          // false
Try It Yourself

How It Works

  1. Function literal. function () {} is callable → true.
  2. String. "text" is not a function → false.
  3. Boolean result. Easy to use in if before invoking.
  4. Official pattern. Matches the jQuery API demo.

Example 2 — Guard an Optional Callback

Call done only when it is a function.

jQuery
function finish(result, done) {
  if ($.isFunction(done)) {
    done(result);
  }
}

finish("ok", function (msg) {
  console.log(msg);  // "ok"
});
finish("ok", null);  // no call, no error
Try It Yourself

How It Works

  1. Optional arg. done may be a function or missing.
  2. Guard. $.isFunction(done) prevents calling null.
  3. Invoke. When true, run done(result).
  4. Safe skip. Second call with null does nothing.

Example 3 — Prefer typeof x === "function"

Same answers — the recommended replacement.

jQuery
var fn = function () {};
var text = "nope";

console.log($.isFunction(fn));             // true
console.log(typeof fn === "function");     // true

console.log($.isFunction(text));           // false
console.log(typeof text === "function");   // false
Try It Yourself

How It Works

  1. Same results. Both APIs agree on functions and non-functions.
  2. No jQuery needed. typeof is built into JavaScript.
  3. Docs guidance. jQuery 3.3+ recommends this replacement.
  4. New projects. Write typeof x === "function" and skip $.isFunction.

Example 4 — $ Is a Function; $() Is Not

Do not confuse the factory with a collection.

jQuery
console.log($.isFunction($));          // true
console.log($.isFunction($("body")));  // false
console.log($.isFunction($.noop));     // true
Try It Yourself

How It Works

  1. Factory. $ is the jQuery function → true.
  2. Collection. $("body") is a jQuery object → false.
  3. noop. $.noop is an empty function → true.
  4. Takeaway. Having .length does not make something a function.

Edge Cases & Pitfalls

Check these before calling unknown values.

deprecated

Removed in jQuery 4.0

Do not add new $.isFunction calls. Migrate to typeof x === "function" before leaving jQuery 3.x.

host

Old IE host methods

As of jQuery 1.3, browser host functions like alert were not guaranteed to detect as functions in old IE. Modern browsers are fine with typeof.

collection

$els is not callable

A jQuery collection is an object. Test the callback parameter, not the selection you built with $().

classes

Classes are functions

class Foo {} is a constructor function — typeof Foo === "function" is true. That is expected.

Browser Support

jQuery.isFunction() is available from jQuery 1.2+ through jQuery 3.x. It is deprecated since 3.3 and removed in 4.0. Prefer typeof x === "function" in all modern browsers.

✓ Deprecated · jQuery 3.x

jQuery.isFunction()

Works in browsers with jQuery 1.2–3.x. For new code use typeof x === "function". Not available in jQuery 4.0.

Legacy jQuery 3.x only
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
$.isFunction() Legacy

Bottom line: Read $.isFunction in legacy jQuery 3.x apps. Write typeof x === "function" for everything new.

Performance Notes

ApproachCostBest for
typeof x === "function"O(1)All new code
$.isFunction(x)O(1)Legacy jQuery 3.x only
$.type(x) === "function"Slightly heavierMulti-type branching

Function checks are cheap. Prefer native typeof for clarity and to avoid a removed jQuery API — not for micro-speed gains.

Key Takeaways

  • Role: $.isFunction(x) → true if callable.
  • Migrate: use typeof x === "function".
  • Guard: check before calling optional callbacks.
  • Note: $ is a function; $() is not.

One line: use $.isFunction to learn legacy callback guards — write typeof x === "function" going forward.

Frequently Asked Questions

jQuery.isFunction(value) returns true when value is callable as a function, and false otherwise. The official example is $.isFunction(function () {}) → true.
Yes. It was deprecated in jQuery 3.3 and removed in jQuery 4.0. Prefer typeof x === "function" in all new code.
For normal functions they agree. The jQuery docs recommend replacing most $.isFunction(x) checks with typeof x === "function".
Yes. Arrow functions, async functions, generators, and classic function declarations/expressions are all functions — they return true.
No. $("div") is an object collection → false. The jQuery factory $ itself is a function → true.
jQuery.type(value) returns the string "function" for functions. jQuery.isFunction(value) returns true for those same values. Prefer a boolean check before calling a callback.
Yes, if an older jQuery that still includes isFunction is loaded. Prefer typeof x === "function" everywhere — it is native and does not need jQuery.

Next: isNumeric()

Test finite numbers and numeric strings with jQuery.

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

8 people found this page helpful