Javascript Array isArray()

The isArray() method checks whether the passed argument is an array or not.

Example


isArray() Syntax

The syntax of the isArray() method is:

Array.isArray(value)

The isArray() method, being a static method, is called using the Array class name.


isArray() Parameters

The isArray() method takes a single parameter:

  • value - The value to be checked.

isArray() Return Value

The isArray() method returns:

  • true if the passed value is Array
  • false if the passed value is not Array

Note: This method always returns false for TypedArray instances.


Example 1: Using isArray() Method

Output

true
false

In the above example, we have used the isArray() method to find out whether fruits and text are arrays or not.

(Array.isArray(fruits)) returns true since fruits is an array object and (Array.isArray(text)) returns false since text is not an array (it's a string).


Example 2: isArray() to Check Other Data Types

Output

true
true
false
false
false