Skip to content
Related Articles
Open in App
Not now

Related Articles

Lodash_.isSequential() Function

Improve Article
Save Article
  • Last Updated : 30 Sep, 2020
Improve Article
Save Article

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.

The _.isSequential() method is used to check whether the given value is a sequential composite type value or not. The examples of a sequential composite type are arrays and arguments.

Syntax:

_.isSequential( value )

Parameters: This method accepts a single parameter as mentioned above and described below:

  • value: It is the value to be checked for a sequential type of value.

Return Value: This method returns a Boolean value. It returns true if the given value is a sequential type, otherwise, it returns false.

Note: This will not work in normal JavaScript because it requires the Lodash contrib library to be installed. Lodash contrib library can be installed using npm install lodash-contrib.

Example 1: In this example, an array is checked with this method.

Javascript




// Defining the lodash-contrib variable 
var _ = require('lodash-contrib');
  
// Using the _.isSequential() method
console.log("The Value is Sequential : " +
  _.isSequential([2, 4, 6, 8]));


Output:

The Value is Sequential : true

Example 2: In this example, an object with key-value pairs is checked with this method.

Javascript




// Defining the lodash-contrib variable 
var _ = require('lodash-contrib');
  
// Using the _.isSequential() method
console.log("The Value is Sequential : " +
  _.isSequential( {1:5, 5:10} ));


Output:

The Value is Sequential : false

Example 3: In this example, a string is checked with this method.

Javascript




// Defining the lodash-contrib variable 
var _ = require('lodash-contrib');
  
// Using the _.isSequential() method
console.log("The Value is Sequential : " +
  _.isSequential("GeeksforGeeks"));


Output:

The Value is Sequential : false

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!