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 136 views
2 answers 142 views
1 answer 97 views
1 answer 157 views
1 answer 115 views
1 answer 112 views
112 views asked Sep 27, 2022 by avibootz
...