How to return tuple from function in TypeScript

1 Answer

0 votes
function getTuple(): [number, number] {
    return [45, 901];
}
  
console.log(getTuple());

const tpl = getTuple();
console.log(tpl[0]);

   
  
  
   
      
/*
run:
            
[45, 901] 
45 
          
*/

 



answered Feb 25, 2022 by avibootz
edited Feb 25, 2022 by avibootz

Related questions

1 answer 147 views
1 answer 223 views
2 answers 214 views
1 answer 134 views
1 answer 163 views
...