Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Lodash _.isArrayLike() Method

  • Last Updated : 29 Jul, 2020

The Lodash _.isArrayLike() method checks if the value is Array-like. A value is considered array-like if it’s not a function and has a value.length that’s an integer greater than or equal to 0 and less than or equal to Number.MAX_SAFE_INTEGER.

Syntax:

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

_.isArrayLike(value)

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

  • value: This parameter holds the value that needs to be Checked for an Array-Like Value.

Return Value: This method returns a Boolean value.



Example 1: This method returns true for an Array.

Javascript




// Defining Lodash variable
const _ = require('lodash'); 
     
var val = [1, 2, 3]
  
// Checking for an ArrayLike
console.log("The Value is ArrayLike : " 
    +_.isArrayLike(val));

Output:

The Value is ArrayLike : true

Example 2: This method returns true for strings as their length can be calculated.

Javascript




// Defining Lodash variable
const _ = require('lodash'); 
     
var val = "GeeksforGeeks";
// Checking for an ArrayLike
console.log("The Value is ArrayLike : "
    +_.isArrayLike(val)); 

Output:

The Value is ArrayLike : true

Example 3: When this method returns false.

Javascript




// Defining Lodash variable
const _ = require('lodash'); 
     
var val = { 1:1 };
// Checking for an ArrayLike
console.log("The Value is ArrayLike : " 
    +_.isArrayLike(val)); 

Output:

The Value is ArrayLike : false

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




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!