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 232 views
1 answer 204 views
2 answers 316 views
2 answers 395 views
1 answer 260 views
1 answer 234 views
1 answer 218 views
...