Lodash _.isArray() Method
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 = "w3wiki" // 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.
Contact Us