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.
// 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 : trueExample 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.
// 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 : falseExample 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.
// 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 : falseNote: This will not work in normal JavaScript because it requires the lodash library to be installed.