How to check if an object is array type in TypeScript

2 Answers

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

 



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

 



answered Jan 24, 2022 by avibootz

Related questions

1 answer 124 views
1 answer 134 views
2 answers 165 views
1 answer 141 views
1 answer 208 views
2 answers 188 views
...