How to create fixed size array in TypeScript

2 Answers

0 votes
let arr: [string, number, number];

arr = ['typescript', 234, 8.362];
  
console.log(arr); 



  
     
/*
run:
     
["typescript", 234, 8.362]
     
*/

 



answered Aug 14, 2022 by avibootz
0 votes
const arr = new Array(5);

console.log(arr);

arr[0] = "typescript";
arr[1] = 2374;

console.log(arr); 





/*
run:
     
[, , , , ] 
["typescript", 2374, , , ] 
     
*/

 



answered Aug 14, 2022 by avibootz

Related questions

1 answer 234 views
2 answers 252 views
1 answer 215 views
1 answer 255 views
1 answer 190 views
1 answer 198 views
198 views asked Sep 27, 2022 by avibootz
...