Lodash - functions 方法



語法

_.functions(object)

從物件自己的可列舉屬性中建立一個函式屬性名稱陣列。

引數

  • object (Object) - 要檢查的物件。

輸出

  • (Array) - 返回函式名稱。

示例

var _ = require('lodash');
 
function Foo() {
   this.a = _.constant('a');
   this.b = _.constant('b');
}
Foo.prototype.c = _.constant('c'); 
console.log(_.functions(new Foo));

將以上程式儲存在 tester.js 中。執行以下命令來執行此程式。

命令

\>node tester.js

輸出

[ 'a', 'b' ]
lodash_object.htm
廣告
© . All rights reserved.