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 115 views
1 answer 128 views
2 answers 156 views
1 answer 136 views
1 answer 199 views
2 answers 181 views
...