_.lt(value, other)
163
_.lt(value, other)
_.lt判断一个value是否小于other
参数
value (*): 需要比较的值
other (*): 需要比较的另外一个值
返回值
(boolean): 如果是value小于other返回true,否则false
例子
_.lt(1, 3); // => true _.lt(3, 3); // => false _.lt(3, 1); // => false
源代码
/** * Checks if `value` is less 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 less than `other`, * else `false`. * @see gt, gte, lte * @example * * lt(1, 3) * // => true * * lt(3, 3) * // => false * * lt(3, 1) * // => false */ //判断一个value是否小于other function lt(value, other) { if (!(typeof value == 'string' && typeof other == 'string')) { //如果value和other不同时是字符串,转换成number对象再比较 value = +value other = +other } return value < other } export default lt