How to get the second element of a set in TypeScript

2 Answers

0 votes
const st = new Set(['typescript', 'java', 'javascript', 'node.js', 'c++']);
  
const second_element = [...st][1];
 
console.log(second_element); 
 
  
  
  
   
/*
run:
   
"java" 
   
*/

 



answered Jul 10, 2022 by avibootz
0 votes
const st = new Set(['typescript', 'java', 'javascript', 'node.js', 'c++']);
  
const [, second_element] = st;
 
console.log(second_element); 
 
  
  
  
   
/*
run:
   
"java" 
   
*/

 



answered Jul 10, 2022 by avibootz
...