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 174 views
1 answer 120 views
2 answers 138 views
1 answer 132 views
1 answer 110 views
...