JavaScript

June 6, 2023

How to use JavaScript Array isArray()

Program to use JavaScript Array isArray() method


let a = [1,2,3,4,5];
let b = Array.isArray(a);
console.log(b);

Output


true

Steps Description

  1. Declare two variable a and b
  2. Initialize two variable a and b with value of array a = [1,2,3,4,5] and b = Array.isArray(a)
  3. Array isArray() method checks whether Array is or not and returns a boolean value.
  4. The value of b variable is displayed with the help of console.log inbuilt function

Program to use JavaScript Array isArray() method


let c = 'Hello World';
let d = Array.isArray(c);
console.log(d);

Output


false

Steps Description

  1. Declare two variable c and d
  2. Initialize two variable c and d with value of string c = 'Hello World' and d = Array.isArray(c)
  3. Array isArray() method checks whether Array is or not and returns a boolean value.
  4. The value of d variable is displayed with the help of console.log inbuilt function

by : Suhel Akhtar

Quick Summary:

Javascript array isArray() method checks is array or not, array is true not false