Javatpoint Logo
Javatpoint Logo

JavaScript Array isArray() Method

The isArray() method is used to test whether the value passed is an array. If it finds the passed value is an array, it returns True. Otherwise, it returns False.

Syntax

Parameter

obj_value: It is the value of the object which is passed for determining whether it is an array or not.

Return

It returns either false or true, depending on the test.

JavaScript Array isArray() Method Example

Let's see the below implementations and determine if the value is an array.

Example1

This example shows a basic implementation of isArray() method.

Test it Now

Output:

JavaScript Array isArray() Method

It is clear that the passed values were not forming any array. Thus, the result is false.

Example2

In this example, we will pass an array and check the resultant.

Test it Now

Output:

JavaScript Array isArray() Method

Hence, the output says that the passed value is an array.

Example3

Let's check what if we pass 'null' as an object value.

Test it Now

Output:

JavaScript Array isArray() Method

Example4

Here is the code implementation where the object value is passed as 'undefined'.

Test it Now

Output:

JavaScript Array isArray() Method

Example5

Determining the object value and invoking the functions accordingly.

Test it Now

Output:

JavaScript Array isArray() Method

Function f1() is invoked because the value passed is an array.

Example6

When we pass the object value as 'True'.

Test it Now

Output:

JavaScript Array isArray() Method

It shows that value is not in the form of an array.


Next TopicJavaScript Array





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA