How to use the functionsIn function from lodash

Find comprehensive JavaScript lodash.functionsIn code examples handpicked from public code repositorys.

lodash.functionsIn is a function in the Lodash library that creates an array of all the own and inherited function property names of an object.

145
146
147
148
149
150
151
152
153
154
module.exports.frequencies         = _.frequencies;
module.exports.fromPairs           = _.fromPairs;
module.exports.fromQuery           = _.fromQuery;
module.exports.functionalize       = _.functionalize;
module.exports.functions           = _.functions;
module.exports.functionsIn         = _.functionsIn;
module.exports.get                 = _.get;
module.exports.getPath             = _.getPath;
module.exports.groupBy             = _.groupBy;
module.exports.gt                  = _.gt;
fork icon19
star icon122
watch icon0

+ 92 other calls in file

650
651
652
653
654
655
656
657
658
659
660
661
662
// => Logs 'b' then 'a'.


const functions = _.functions(_);
console.log(functions); // => ['add', 'after', 'ary', 'assign', ...]


const functionsIn = _.functionsIn(_);
console.log(functionsIn); // => ['add', 'after', 'ary', 'assign', ...]


const get = _.get({ 'a': [{ 'b': { 'c': 3 } }] }, 'a[0].b.c');
console.log(get); // => 3
fork icon0
star icon4
watch icon0

+ 15 other calls in file

How does lodash.functionsIn work?

When you use lodash.functionsIn in your JavaScript code, you are using a function that creates an array of all the own and inherited function property names of an object. To use lodash.functionsIn, you pass an object as the first argument. The function then recursively traverses the prototype chain of the object and collects the names of all function properties it encounters. The resulting array contains all the function property names of the object and its prototypes, including functions defined on the global Object prototype. Here is an example of using lodash.functionsIn to get all the function property names of an object: javascript Copy code {{{{{{{ const _ = require('lodash'); function MyClass() { this.foo = function() {}; this.bar = function() {}; } MyClass.prototype.baz = function() {}; const obj = new MyClass(); const functionNames = _.functionsIn(obj); console.log(functionNames); In this example, we define a MyClass constructor function with three methods: foo, bar, and baz. We then create an instance of MyClass and pass it to _.functionsIn to get an array of all the function property names of the object and its prototypes. The resulting functionNames array is: css Copy code {{{{{{{ class="!whitespace-pre hljs language-css">[ 'foo', 'bar', 'baz', 'hasOwnProperty', 'valueOf', ... ] This shows how lodash.functionsIn can be used to easily get all the function property names of an object, including those defined on its prototypes.

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
const _ = require("lodash");

function MyClass() {
  this.foo = function () {};
  this.bar = function () {};
}

MyClass.prototype.baz = function () {};

const obj = new MyClass();

const functionNames = _.functionsIn(obj);
console.log(functionNames);

In this example, we define a MyClass constructor function with three methods: foo, bar, and baz. We then create an instance of MyClass and pass it to _.functionsIn to get an array of all the function property names of the object and its prototypes. The resulting functionNames array is: css Copy code

Other functions in lodash

Sorted by popularity

function icon

lodash.get is the most popular function in lodash (7670 examples)