📜  Lodash _.functionsIn() 方法

📅  最后修改于: 2022-05-13 01:56:27.086000             🧑  作者: Mango

Lodash _.functionsIn() 方法

Lodash _.functionsIn() 方法从给定对象的自身和继承的可枚举属性创建一个函数属性名称数组

句法:

_.functionsIn( object )

参数:此方法接受上面提到的两个参数,如下所述:

  • object:这是要检查的对象。

返回值:此方法返回一个属性数组。

示例 1:

Javascript
// Defining Lodash variable 
const _ = require('lodash'); 
  
  
// Defining object function
function GFGfunc() {
  this.Geek1 = _.constant('gfg');
  this.Geek2 = _.constant('gfg');
}
   
// Use of function
console.log(_.functionsIn(new GFGfunc));


Javascript
// Defining Lodash variable 
const _ = require('lodash'); 
  
  
// Defining object function
function GFGfunc() {
  this.Geek1 = _.constant('gfg');
  this.Geek2 = _.constant('gfg');
}
  
GFGfunc.prototype.Geek3 = _.constant('gfg');
   
// Use of function
console.log(_.functionsIn(new GFGfunc));


输出:

[ 'Geek1', 'Geek2' ]

示例 2:

Javascript

// Defining Lodash variable 
const _ = require('lodash'); 
  
  
// Defining object function
function GFGfunc() {
  this.Geek1 = _.constant('gfg');
  this.Geek2 = _.constant('gfg');
}
  
GFGfunc.prototype.Geek3 = _.constant('gfg');
   
// Use of function
console.log(_.functionsIn(new GFGfunc));

输出:

[ 'Geek1', 'Geek2', 'Geek3' ]

注意:这在普通 JavaScript 中不起作用,因为它需要安装 lodash 库,并且可以使用npm install lodash 安装