Lodash - forInRight 方法



語法

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

此方法類似於 _.forIn,不同之處在於它按相反的順序迭代物件中的屬性。

引數

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

  • [iteratee=_.identity] (Function) − 每進行一次迭代都會呼叫的函式。

 輸出

  • (Object) − 返回物件。

示例

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

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

命令

\>node tester.js

 輸出

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