Lodash _.isArray() Method
Last Updated :
31 Oct, 2023
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
const _ = require( 'lodash' );
let val = [1, 2, 3]
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
const _ = require( 'lodash' );
let val = "GeeksforGeeks"
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
const _ = require( 'lodash' );
let val = { 1: 1 }
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
Share your thoughts in the comments
Please Login to comment...