Underscore.JS negate 方法 语法 _.negate(predicate)JavaScriptCopy negate方法返回传递函数的反转版本。 示例 var _ = require('underscore'); var isEven = function(value) { return value % 2 == 0 }; var isOdd = _.negate(isEven); console.log(isEven(2)); console.log(isOdd(2));JavaScriptCopy 将上述程序保存在 tester.js 中。运行以下命令来执行该程序。 命令: >node tester.jsJavaScriptCopy 输出 true falseJavaScriptCopy