Open In App

Lodash _.isLength() Method

Last Updated : 30 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Lodash _.isLength() Method checks whether the given value is an Array-like length or not and returns the corresponding boolean value.

Syntax:

_.isLength(value);

Parameters:

  • value: This parameter holds the value that needs to be checked for an Array-like length.

Return Value:

This method returns a Boolean value(Returns true if the given value is an Array-like length, else false).

Example 1: In this example, it is printing true in the console as 100 is a valid length.

Javascript




// Defining Lodash variable
const _ = require('lodash');
 
// Checking for Length
console.log("The Value is Length : "
    + _.isLength(100));


Output:

The Value is Length : true

Example 2: In this example, it is printing false in the console as Infinity and string are not valid lengths.

Javascript




// Defining Lodash variable
const _ = require('lodash');
 
// Checking for Length
console.log("The Value is Length : "
    + _.isLength(Infinity));
console.log("The Value is Length : "
    + _.isLength("len"));


Output:

The Value is Length : false 
The Value is Length : false

Example 3: In this example, it is printing true in the console as Number.MAX_VALUE return a number that is a valid length.

Javascript




// Defining Lodash variable
const _ = require('lodash');
 
// Checking for Length
console.log("The Value is Length : "
    + _.isLength(Number.MAX_VALUE));


Output:

The Value is Length : true


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads