How to declare and initialize a tuple in TypeScript

2 Answers

0 votes
let tpl: [number, string] = [1, "TypeScript"];


for (var t of tpl) {
    console.log(t); 
}
 



 
/*
 
run:
 
1 
"TypeScript" 

*/

 



answered Oct 23, 2021 by avibootz
0 votes
let tpl: [number, string, boolean] = [1, "TypeScript", true];


for (var t of tpl) {
    console.log(t); 
}
 



 
/*
 
run:
 
1 
"TypeScript" 
true 

*/

 



answered Oct 23, 2021 by avibootz

Related questions

1 answer 156 views
1 answer 195 views
1 answer 157 views
1 answer 142 views
...