Lodash - keysIn 方法
語法
_.keysIn(object)
建立 object 自有和繼承的可列舉屬性的陣列。
引數
object (物件) - 要查詢的物件。
輸出
(陣列) - 返回屬性名稱的陣列。
示例
var _ = require('lodash');
function Foo() {
this.a = 1;
this.b = 2;
}
Foo.prototype.c = 3;
var result = _.keysIn(new Foo);
console.log(result);
將上述程式儲存在 tester.js 中。執行以下命令來執行此程式。
命令
\>node tester.js
輸出
[ 'a', 'b', 'c' ]
lodash_object.htm
廣告