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.
Syntax
Start with these common calls. Keep them short and readable.
Function literal.function () {} is callable → true.
String."text" is not a function → false.
Boolean result. Easy to use in if before invoking.
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
Same results. Both APIs agree on functions and non-functions.
No jQuery needed.typeof is built into JavaScript.
Docs guidance. jQuery 3.3+ recommends this replacement.
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.