June 6, 2023
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
andb
- Initialize two variable
a
andb
with value of arraya = [1,2,3,4,5]
andb = 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
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
andd
- Initialize two variable
c
andd
with value of stringc = 'Hello World'
andd = 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
by : Suhel Akhtar
Quick Summary:
Javascript array isArray() method checks is array or not, array is true not false