How to use JavaScript Array isArray()
Array isArray
On this page
Array isArray() Method
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
- Declare two variable a and b
- Initialize two variable a and b with value of array a = [1,2,3,4,5] and b = Array.isArray(a)
- Array isArray() method checks whether Array is or not and returns a boolean value.
- The value of b variable is displayed with the help of console.log inbuilt function
Array isArray() Method
Program to use JavaScript Array isArray() method
let c = 'Hello World';
let d = Array.isArray(c);
console.log(d);
Output
false
Steps Description
- Declare two variable c and d
- Initialize two variable c and d with value of string c = ‘Hello World’ and d = Array.isArray(c)
- Array isArray() method checks whether Array is or not and returns a boolean value.
- The value of d variable is displayed with the help of console.log inbuilt function