Lodash _.overSome() 方法
Lodash _.overSome()方法用于创建一个函数,该函数在使用接收到的参数调用时检查是否有任何谓词返回真值。
句法:
_.overSome( predicates )
参数:此方法接受一个如上所述和如下所述的参数:
- 谓词:这是要调用的谓词。
返回值:此方法返回一个新函数。
示例 1:
Javascript
// Requiring the lodash library
const _ = require("lodash");
// Use of _.overSome() method
var func = _.overSome([Boolean, isFinite]);
// Saving the result
let gfg1 = func(10);
let gfg2 = func(-5);
let gfg3 = func(null);
let gfg4 = func(NaN);
// Printing the output
console.log(gfg1);
console.log(gfg2);
console.log(gfg3);
console.log(gfg4);
Javascript
// Requiring the lodash library
const _ = require("lodash");
// Use of _.overSome() method
var func = _.overSome([Math.min, Math.max]);
// Saving the result
let gfg = func(2, 4, -6, 8);
// Printing the output
console.log(gfg);
输出:
true
true
true
false
示例 2:
Javascript
// Requiring the lodash library
const _ = require("lodash");
// Use of _.overSome() method
var func = _.overSome([Math.min, Math.max]);
// Saving the result
let gfg = func(2, 4, -6, 8);
// Printing the output
console.log(gfg);
输出 :
true