Underscore.js _.gte() 方法
这 _。 gte()方法检查每个参数是否大于或等于其下一个参数。
句法:
_.gte( val1, val2,..., valn );
参数:此方法需要 n 个值对其进行操作。
返回值:此方法返回一个布尔值。
注意:这在普通 JavaScript 中不起作用,因为它需要安装 underscore.js contrib 库。
underscore.js contrib 库可以使用npm install underscore-contrib –save 安装。
示例 1:
Javascript
// Defining underscore contrib variable
var _ = require('underscore-contrib');
var greater = _.gte(4, 1, 1);
console.log("Each argument is greater than or"+
" equal to its next argument :",greater);
Javascript
// Defining underscore contrib variable
var _ = require('underscore-contrib');
var greater = _.gte(4, 3, 2, 1);
console.log("Each argument is greater than or"+
" equal to its next argument :",greater);
Javascript
// Defining underscore contrib variable
var _ = require('underscore-contrib');
var greater = _.gte(4, 3, 2, 1, 44);
console.log("Each argument is greater than or"+
" equal to its next argument :",greater);
输出:
Each argument is greater than or equal to
its next argument : true
示例 2:
Javascript
// Defining underscore contrib variable
var _ = require('underscore-contrib');
var greater = _.gte(4, 3, 2, 1);
console.log("Each argument is greater than or"+
" equal to its next argument :",greater);
输出:
Each argument is greater than or equal to
its next argument : true
示例 3:
Javascript
// Defining underscore contrib variable
var _ = require('underscore-contrib');
var greater = _.gte(4, 3, 2, 1, 44);
console.log("Each argument is greater than or"+
" equal to its next argument :",greater);
输出:
Each argument is greater than or equal
to its next argument : false