Lodash _.isFunction() method

Beginner
⏱️ 6 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.isFunction(value) recognizes callable objects beyond naive checks.
  • Which variants count (sync, arrow-like, async, generators, proxies).
  • Why ordinary POJOs, primitives, and regex literals fail.
  • When lodash tagging aligns or differs from typeof.

Prerequisites

You can declare JavaScript functions and know basic callable terminology.

  • You understand arrow versus traditional function declarations.
  • Try-it labs load lodash from the CDN.

Overview

Use _.isFunction before invoking callbacks, normalizing middleware, or guarding Higher-Order API surfaces—especially when unknown payloads pretend to be callables.

Tagged callables

Matches Function, GeneratorFunction, AsyncFunction, Proxy callables.

Safe guards

Filter hooks before fn() reduces runtime TypeErrors.

Non-callables out

Plain objects, regex literals, primitives exit fast.

Syntax

javascript
_.isFunction(value)
  • value: any value to test.
  • Returns: true if classified as a Function-like callable per lodash tags; otherwise false.
1

Traditional and arrow functions

Both declaration styles register as native callables.

javascript
import isFunction from "lodash/isFunction";

console.log(
  "namedFn: " + isFunction(function bump(n) { return n + 1; }) + "\n" + // true
  "arrowFn: " + isFunction(() => 42)                                // true
);
Try it Yourself
2

Objects, regex literals, and primitives

These values lack Function tagging even when they relate to behavior elsewhere.

javascript
import isFunction from "lodash/isFunction";

console.log(
  "plainObj: " + isFunction({ run: function () {} }) + "\n" + // false (object, not the inner fn)
  "regexp: " + isFunction(/match-me/) + "\n" +                // false
  "numberPrim: " + isFunction(0)                              // false
);
Try it Yourself
3

Async functions and class constructors

Modern callable forms remain detected; ES classes are constructors.

javascript
import isFunction from "lodash/isFunction";

console.log(
  "asyncFn: " + isFunction(async function fetchData() {}) + "\n" + // true
  "classCtor: " + isFunction(class Widget {})                     // true
);
Try it Yourself

📋 _.isFunction vs related checks

APIMatches
_.isFunction(x)Tagged Function / Generator / Async / Proxy callables.
typeof x === "function"Often matches; lodash centralizes edge-case tagging rationale.
x instanceof FunctionGenerally aligned for ordinary functions; odd prototypes may diverge.
_.isObject(x)Broader—includes non-callables that still pass object checks.

Pitfalls to avoid

Hooks

Properties holding functions

_.isFunction(obj) inspects obj itself—grab obj.handler before testing.

DOM

Host objects

Some browsers expose callable DOM APIs—behavior follows engine tagging; validate expectations manually.

Classes

Instances versus constructors

The class body is a function; instances are ordinary objects unless explicitly callable.

❓ FAQ

No. Ordinary arrows still carry the Function tag and return true—same as async functions and generators (their respective tags are included).
Lodash documents historically guarding Safari quirks around constructors vs typed arrays; the tag-based path aligns classify-callables consistently across engines.
Class declarations produce callable constructor functions under the hood, so lodash follows native tagging rules.
No. Regexps carry different tags and yield false.

Summary

  • Purpose: classify values as callable Function objects across modern variants.
  • Remember: test the exact reference you intend to invoke—not its parent object.
  • Next: explore more on Lodash _.isInteger().
Did you know?

_.isFunction classifies values whose tags are [object Function], [object GeneratorFunction], [object AsyncFunction], or [object Proxy]—so ES classes (class Foo {}) register as functions because they are callable constructors.

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.

6 people found this page helpful