Lodash _.isArray() Method

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

Syntax:

_.isArray( value )

Parameters: This method accepts a single parameter as mentioned above and described below:

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

Return Value: This method returns a Boolean value.

Example 1: When this method returns true.



Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

The Value is Array : true

Example 2: When this method returns false for strings.

Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

The Value is Array : false

Example 3:

Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

The Value is Array : false

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

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.