Lodash _.functions() method

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

What you’ll learn

  • How _.functions(object) returns the names of an object’s own enumerable function properties.
  • Why _.functions(new MyClass()) returns []—and when to reach for _.functionsIn instead.
  • Practical patterns: discovering a plain-object API, validating module shape, and dispatching by name.
  • Try each example in the editor (?tryit=1, 2, 3) with Lodash from a CDN.

Prerequisites

Understand the difference between own properties and properties inherited via the prototype chain—this method’s entire personality is “own only.”

  • Class methods live on the prototype: a value declared inside class is not an own property of an instance.
  • Enumerable means visible to Object.keys: non-enumerable methods (like inherited ones defined via Object.defineProperty without enumerable: true) are skipped.
  • Returns an array of strings: not the function values themselves—just their names.

Overview

_.functions scans an object’s own enumerable string keys, keeps the ones whose value is a function, and returns those names in Lodash key iteration order. It’s a pure inspection helper—no mutation, no side effects, no recursion into the prototype chain.

Own keys only

Prototype methods are not included—the most common surprise on this method.

Key-order result

For plain objects, expect the same practical order you get from own-key iteration. Sort explicitly when needed.

Names, not values

Use the names to dispatch (obj[name](...)), document the API surface, or assert against an expected list.

Syntax

javascript
_.functions(object)
  • object: the object to inspect.
  • Returns: an array of own enumerable function property names.
  • Does not include: inherited properties, symbol keys, or non-enumerable properties.
1

List own function properties from a plain object

For a plain object literal, every method is an own property, so they all show up in own-key iteration order.

javascript
import functions from "lodash/functions";

const sampleObject = {
  name: "John Doe",
  age: 30,
  sayHello() {
    console.log("Hello!");
  },
  calculate(a, b) {
    return a + b;
  }
};

functions(sampleObject);
// -> ["sayHello", "calculate"]
//      ^^^^^^^^^^   ^^^^^^^^^
//      own function names only
Try it Yourself
2

Prototype methods: own vs inherited

Methods placed on a constructor’s prototype are inherited, not own, so _.functions skips them. _.functionsIn walks the prototype chain and reports those enumerable inherited methods. (ES class methods are non-enumerable, so they hide from both helpers—see the pitfalls section below.)

javascript
import functions   from "lodash/functions";
import functionsIn from "lodash/functionsIn";

function MathOperations() {}
MathOperations.prototype.add      = function (a, b) { return a + b; };
MathOperations.prototype.subtract = function (a, b) { return a - b; };

const math = new MathOperations();

functions(math);
// -> []
//    add / subtract live on MathOperations.prototype, not on `math`.

functionsIn(math);
// -> ["add", "subtract"]
//    *In variants walk the prototype chain (enumerable keys only).
Try it Yourself
3

Validate a module’s required surface

A perfect use case: assert that an object exposes a known set of method names before plugging it into a pipeline.

javascript
import functions from "lodash/functions";

const authModule = {
  login:     async () => { /* ... */ },
  logout:    async () => { /* ... */ },
  fetchData: async () => { /* ... */ },
  baseUrl:   "https://api.example.com" // not a function
};

const required = ["login", "logout", "fetchData"];
const exposed  = functions(authModule);
// exposed -> ["login", "logout", "fetchData"]

const missing = required.filter((name) => !exposed.includes(name));
// missing -> []   ()
Try it Yourself

📋 _.functions vs _.functionsIn vs Object.keys + filter

Topic_.functions_.functionsInObject.keys(...).filter(...)
Own propertiesYesYesYes
Inherited enumerable propertiesNoYesNo
Filters non-functionsBuilt-inBuilt-inManual with typeof === "function"
Result orderSortedSortedInsertion order
ReturnsArray of namesArray of namesArray of names

Reach for _.functions on plain data objects. Switch to _.functionsIn the moment class instances or mixin-based composition is involved.

Pitfalls to avoid

Class

Class instances look empty

_.functions(new MyClass()) returns [] because methods live on the prototype. ES class methods are also non-enumerable, so _.functionsIn may still return [].

Order

Order is not an API contract for workflows

If method order matters, sort the returned names explicitly or maintain an ordered allow-list.

Names

Returns names, not the functions themselves

If you need callable references, map back: functions(obj).map((name) => obj[name]).

Symbols

Symbol-keyed methods are skipped

If your API uses well-known symbols (like Symbol.iterator), pair this with Object.getOwnPropertySymbols.

❓ FAQ

An array of the object's OWN enumerable property names whose values are functions. Inherited methods are NOT included.
Methods declared inside a class body live on the prototype, not on the instance. _.functions only inspects own properties, so they're skipped. Note that _.functionsIn still requires inherited methods to be enumerable.
_.functions returns own enumerable function names only. _.functionsIn additionally walks the prototype chain and returns inherited enumerable function names too.
No. It follows Lodash's own-key iteration order, similar to Object.keys(). If you need alphabetical output, sort the returned array yourself.
Yes. Anything for which _.isFunction returns true is included—regular functions, arrow functions, async functions, and generator functions.
Use _.includes(_.functions(obj), 'methodName'), or for stricter checks combine with _.has / typeof obj.methodName === 'function'.

Summary

Did you know?

_.functions only looks at own enumerable properties. ES class methods live on the prototype and are non-enumerable, so _.functions(new MyClass()) returns []; _.functionsIn can include inherited methods only when they are enumerable.

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