Skip to content

forInRight

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

此方法与 _.forIn 类似,不同之处在于它以相反的顺序迭代 object 的属性。

¥This method is like _.forIn except that it iterates over properties of object in the opposite order.

新增于

¥Since

2.0.0

参数

¥Arguments

  1. object (对象):要迭代的对象。

    ¥object (Object): The object to iterate over.

  2. [iteratee=_.identity] (函数):每次迭代调用的函数。

    ¥[iteratee=_.identity] (Function): The function invoked per iteration.

返回

¥Returns

(对象):返回 object

¥(Object): Returns object.

示例

¥Example

js
function Foo() {
  this.a = 1;
  this.b = 2;
}

Foo.prototype.c = 3;

_.forInRight(new Foo, function(value, key) {
  console.log(key);
});
// => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.

Lodash v4.17 中文网 - 粤ICP备13048890号