📜  Lodash _.isIncreasing() 方法

📅  最后修改于: 2022-05-13 01:56:37.595000             🧑  作者: Mango

Lodash _.isIncreasing() 方法

Lodash _.isIncreasing() 方法检查给定值是否单调递增(每个参数都大于前一个参数)。

句法:

_.isIncreasing(val1, val2, ..., valn);

参数:此方法需要 n 个值来检查递增顺序。

返回值:此方法返回一个布尔值(如果给定值增加则返回真,否则返回假)。

注意:这在普通 JavaScript 中不起作用,因为它需要安装 lodash.js contrib 库。 Lodash.js contrib 库可以使用npm install lodash-contrib 安装

示例 1:

Javascript
// Defining lodash contrib variable 
var _ = require('lodash-contrib'); 
  
// Check for increasing order
console.log("The Value is Increasing order : " 
    + _.isIncreasing(1, 2, 3, 4));


Javascript
// Defining lodash contrib variable 
var _ = require('lodash-contrib'); 
  
// Check for increasing order
console.log("The Value is Increasing : " 
    + _.isIncreasing(3, 2, 1, 2));


Javascript
// Defining lodash contrib variable 
var _ = require('lodash-contrib'); 
  
// Check for increasing order
console.log("The Value is Increasing : " 
    + _.isIncreasing('a', 'b'));
      
console.log("The Value is Increasing : " 
    + _.isIncreasing('c', 'b', 'a'));


Javascript
// Defining lodash contrib variable 
var _ = require('lodash-contrib'); 
  
// Check for increasing order
console.log("The Value is Increasing : " 
    + _.isIncreasing("Geeks", "GFG"));
      
console.log("The Value is Increasing : " 
    + _.isIncreasing('g', 'G'));


输出:

The Value is Increasing order : true

示例 2:

Javascript

// Defining lodash contrib variable 
var _ = require('lodash-contrib'); 
  
// Check for increasing order
console.log("The Value is Increasing : " 
    + _.isIncreasing(3, 2, 1, 2));

输出:

The Value is Increasing : false

示例 3:

Javascript

// Defining lodash contrib variable 
var _ = require('lodash-contrib'); 
  
// Check for increasing order
console.log("The Value is Increasing : " 
    + _.isIncreasing('a', 'b'));
      
console.log("The Value is Increasing : " 
    + _.isIncreasing('c', 'b', 'a'));

输出:

The Value is Increasing : true
The Value is Increasing : false

示例 4:

Javascript

// Defining lodash contrib variable 
var _ = require('lodash-contrib'); 
  
// Check for increasing order
console.log("The Value is Increasing : " 
    + _.isIncreasing("Geeks", "GFG"));
      
console.log("The Value is Increasing : " 
    + _.isIncreasing('g', 'G'));

输出:

The Value is Increasing : false
The Value is Increasing : false