Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptLodash _.isSequential() Function

Lodash _.isSequential() Function

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("neveropen"));


Output:

The Value is Sequential : false

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments