Open In App

Lodash _.isArrayLikeObject() Method

Lodash _.isArrayLikeObject() method checks whether the given value is an Array-like Object or not. This method is similar to the _.isArrayLike() method except that it also checks if the value is an object or not.

Syntax:

_.isArrayLikeObject( value );

Parameters:

Return Value:

This method returns a Boolean value.



Example 1: In this example, this method returns true for an Array as it is an object also.




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

Output:



The Value is ArrayLikeObject : true

Example 2: In this example, this method returns false for the string as it is not an object.




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

Output:

The Value is ArrayLikeObject : false

Example 3: In this example, this method is returning false as given value is not an array-like object.




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

Output:

The Value is ArrayLikeObject : 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.


Article Tags :