Lodash _.over() 方法
Lodash _.over()方法用于创建一个函数,该函数使用它接收的参数调用 iteratee 并返回其结果。
句法:
_.over(iteratees)
参数:此方法接受一个如上所述和如下所述的参数:
- iteratee:要调用的迭代对象。
返回:此方法返回一个新函数。
示例 1:
Javascript
// Requiring the lodash library
const _ = require("lodash");
// Use of _.over() method
var func = _.over([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 _.over() method
var func = _.over([Math.min, Math.max]);
// Saving the result
let gfg = func(5, 10, -5, 20);
// Printing the output
console.log(gfg);
输出:
[true, true]
[true, true]
[true, false]
[true, false]
示例 2:
Javascript
// Requiring the lodash library
const _ = require("lodash");
// Use of _.over() method
var func = _.over([Math.min, Math.max]);
// Saving the result
let gfg = func(5, 10, -5, 20);
// Printing the output
console.log(gfg);
输出:
[-5, 20]