How to get the second element of a set in Node.js

2 Answers

0 votes
const st = new Set(['node.js', 'python', 'javascript', 'typescript', 'c++']);
 
const second_element = [...st][1];
 
console.log(second_element); 

 
 
 
  
/*
run:
  
python
  
*/

 



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

 
 
 
  
/*
run:
  
python
  
*/

 



answered Jul 10, 2022 by avibootz

Related questions

2 answers 168 views
1 answer 113 views
2 answers 130 views
1 answer 126 views
1 answer 105 views
...