Lodash _.functionsIn() method

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

What you’ll learn

  • How _.functionsIn(object) returns function names from own and inherited enumerable string keys.
  • Why _.functionsIn sees constructor/prototype-assigned methods, but not non-enumerable ES class methods.
  • How it differs from _.functions, which only reports own methods.
  • Try each example in the editor (?tryit=1, 2, 3) with Lodash from a CDN.

Prerequisites

Review _.functions() first. The In suffix means inherited enumerable keys are included.

  • Enumerable matters: inherited methods must be enumerable to appear.
  • Class syntax caveat: ES class methods are non-enumerable on the prototype, so they usually do not show up.

Overview

_.functionsIn scans an object and its prototype chain, keeps enumerable string-keyed properties whose values are functions, and returns their names in Lodash key iteration order. It is useful for old constructor/prototype APIs, mixins, and objects whose inherited methods are deliberately public.

Own + inherited

Unlike _.functions, inherited enumerable function names are included.

Key-order names

The returned array follows Lodash key iteration; sort it explicitly for documentation or snapshot tests.

Enumerable only

Prototype traversal does not mean all methods. Non-enumerable class methods remain hidden.

Syntax

javascript
_.functionsIn(object)
  • object: object to inspect, including its prototype chain.
  • Returns: an array of own and inherited enumerable function property names.
  • Does not include: non-enumerable methods or symbol-keyed methods.
1

Include enumerable prototype methods

Methods assigned directly to a constructor’s prototype are enumerable by default, so _.functionsIn includes them.

javascript
import functionsIn from "lodash/functionsIn";

function Animal(name) {
  this.name = name;
}

Animal.prototype.sayHello = function () {
  return `Hello, I'm ${this.name}!`;
};

const dog = new Animal("Buddy");

functionsIn(dog);
// -> ["sayHello"]
Try it Yourself
2

functions vs functionsIn

_.functions reports only own methods. _.functionsIn includes enumerable methods inherited from prototypes too.

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

function Plugin() {
  this.setup = function () {};
}

Plugin.prototype.run = function () {};
Plugin.prototype.stop = function () {};

const plugin = new Plugin();

functions(plugin);
// -> ["setup"]

functionsIn(plugin);
// -> ["setup", "run", "stop"]
Try it Yourself
3

ES class methods are non-enumerable

This is the easy mistake: functionsIn walks the prototype chain, but it still respects enumerability. ES class methods are non-enumerable, so they do not appear.

javascript
import functionsIn from "lodash/functionsIn";

class MathOperations {
  add(a, b) { return a + b; }
  subtract(a, b) { return a - b; }
}

const math = new MathOperations();

functionsIn(math);
// -> []
// ES class methods are inherited, but they are non-enumerable.

Object.keys(MathOperations.prototype);
// -> []
Try it Yourself

📋 _.functionsIn vs _.functions vs reflection helpers

Topic_.functionsIn_.functionsReflect.ownKeys + filtering
Own enumerable functionsYesYesManual
Inherited enumerable functionsYesNoManual prototype walk
Non-enumerable class methodsNoNoYes, if you inspect descriptors
Symbol-keyed methodsNoNoYes
Result orderLodash key orderLodash key orderYour code decides

Use _.functionsIn for enumerable mixin-style APIs. Use reflection helpers when you need complete class/introspection coverage.

Pitfalls to avoid

Class

Expecting ES class methods to appear

They are non-enumerable. _.functionsIn(new MyClass()) often returns [], even though methods exist on the prototype.

Surface

Including more than your public API

Inherited enumerable helper methods from mixins or prototypes may be included. Filter by an allow-list before exposing or invoking names from untrusted objects.

Order

Do not infer API priority from order

The returned array follows key iteration across own and inherited properties. Sort or provide an allow-list when order matters.

Names

Returns names, not callable references

Map back carefully: functionsIn(obj).map((name) => obj[name]). Preserve this when invoking methods.

❓ FAQ

An array of property names whose values are functions, including both own and inherited enumerable string-keyed properties.
_.functions inspects only own enumerable function properties. _.functionsIn also walks inherited enumerable properties from the prototype chain.
Usually no. ES class methods are non-enumerable on the prototype, and _.functionsIn only reports enumerable function properties. Constructor/prototype assignments are enumerable by default, so those often appear.
No. It follows Lodash key iteration order across own and inherited enumerable keys. Sort the returned array yourself if you need alphabetical output.
No. It returns string-keyed property names. Use Object.getOwnPropertySymbols and prototype traversal manually if symbols matter.
Use it for introspecting mixin-style objects, old constructor/prototype APIs, and objects whose enumerable inherited methods are intentionally part of the public surface.

Summary

Did you know?

_.functionsIn walks up the prototype chain, but it still only sees enumerable function properties. Methods created with ES class syntax are non-enumerable, so they will not show up unless you define or expose them differently.

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