How to check if an object is array type in JavaScript

2 Answers

0 votes
const o = [5, 7, 3, 0, 1];
 
if (Array.isArray(o)) {
    console.log("array");
}
 
 
 
/*
run:
 
"array"
 
*/

 



answered Nov 5, 2020 by avibootz
edited Jan 24, 2022 by avibootz
0 votes
const o = Array(50);
 
if (Array.isArray(o)) {
    console.log("array");
}
 
 
 
/*
run:
 
"array"
 
*/

 



answered Nov 5, 2020 by avibootz
edited Jan 24, 2022 by avibootz

Related questions

1 answer 153 views
1 answer 134 views
2 answers 197 views
2 answers 262 views
1 answer 171 views
1 answer 175 views
1 answer 136 views
...