Lodash - forOwnRight 方法



語法

_.forOwnRight(object, [iteratee=_.identity])

此方法類似於 _.forOwn,但它按照相反的順序對物件的屬性進行迭代。

引數

  • object (物件) − 要進行迭代的物件。

  • [iteratee=_.identity] (函式) − 每次迭代呼叫的函式。

輸出

  • (物件) − 返回物件。

示例

var _ = require('lodash');
function Foo() {
   this.a = 1;
   this.b = 2;
} 
Foo.prototype.c = 3;
_.forOwnRight(new Foo, function(value, key) {
   console.log(key);
});

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

命令

\>node tester.js

輸出

b
a
lodash_object.htm
廣告
© . All rights reserved.