_.gt(value, other)
124
_.gt(value, other)
_.gt判断一个值是否比另外一个值大
如果value比other大,返回true,否则false
参数
value (*): 需要比较的值
other (*): 需要与value比较的值
返回值
(boolean): 如果value比other大,返回true,否则false
例子
_.gt(3, 1); // => true _.gt(3, 3); // => false _.gt(1, 3); // => false
源代码
/** * Checks if `value` is greater than `other`. * * @since 3.9.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. * @returns {boolean} Returns `true` if `value` is greater than `other`, * else `false`. * @see gte, lt, lte * @example * * gt(3, 1) * // => true * * gt(3, 3) * // => false * * gt(1, 3) * // => false */ //判断一个值是否比另外一个值大 //如果value比other大,返回true,否则false function gt(value, other) { if (!(typeof value == 'string' && typeof other == 'string')) { //如果value和other不同时是string类型,就转换成数字 value = +value other = +other } return value > other//返回比较的结果 } export default gt