codecamp

Lodash _.negate

_.negate(predicate)

创建一个针对断言函数 func 结果取反的函数。 func 断言函数被调用的时候,this 绑定到创建的函数,并传入对应参数。

添加版本

3.0.0

参数

  1. predicate (Function): 需要对结果取反的函数。

返回

(Function): 返回一个新的取反函数。

例子

function isEven(n) {  return n % 2 == 0;} _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
// => [1, 3, 5]


Lodash _.memoize
Lodash _.once
温馨提示
下载编程狮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; }