codecamp

Lodash _.forInRight

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

这个方法类似_.forIn。 除了它是反方向开始遍历object的。

添加版本

2.0.0

参数

  1. object (Object): 要遍历的对象。
  2. [iteratee=_.identity] (Function): 每次迭代时调用的函数。

返回

(Object): 返回 object。

例子

function Foo() {  this.a = 1;  this.b = 2;} Foo.prototype.c = 3;
 _.forInRight(new Foo, function(value, key) {  console.log(key);});
// => 输出 'c', 'b', 然后 'a', `_.forIn` 会输出 'a', 'b', 然后 'c'。


Lodash _.forIn
Lodash _.forOwn
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

Lodash 简介

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }