How to use tuple in TypeScript

1 Answer

0 votes
let tpl = [10, "TypeScript", "C++", "Java", 12]; 
 
console.log(tpl);
console.log(tpl.length);
 
tpl.push("C");
console.log(tpl);
console.log(tpl.length);
 
tpl.pop();
tpl.pop();
console.log(tpl);
console.log(tpl.length);
 
tpl[0] = 84791;
console.log(tpl);
 
 
 
 
 
  
/*
run:
  
[10, "TypeScript", "C++", "Java", 12] 
5 
[10, "TypeScript", "C++", "Java", 12, "C"] 
6 
[10, "TypeScript", "C++", "Java"] 
4 
[84791, "TypeScript", "C++", "Java"] 
  
*/

 



answered Nov 26, 2021 by avibootz
edited Aug 13, 2022 by avibootz

Related questions

1 answer 123 views
123 views asked Aug 13, 2022 by avibootz
1 answer 153 views
1 answer 155 views
2 answers 242 views
1 answer 157 views
...