Open In App

Lodash _.isArray() Method

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

Lodash _.isArray() method checks if the given value can be classified as an Array Value or not.

Syntax:

_.isArray(value);

Parameters:

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

Return Value:

This method returns a Boolean value.

Example 1: In this example, we are checking whether the given value is an array or not and print the result in the console by the use of the _.isArray() method.

Javascript




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


Output:

The Value is Array : true

Example 2: In this example, we are checking whether the given value is an array or not and print the result in the console by the use of the _.isArray() method.

Javascript




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


Output:

The Value is Array : false

Example 3: In this example, we are checking whether the given value is an array or not and print the result in the console by the use of the _.isArray() method.

Javascript




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


Output:

The Value is Array : false

Note: This will not work in normal JavaScript because it requires the lodash library to be installed.



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

Similar Reads