How to get the N element of a set in JavaScript

1 Answer

0 votes
const st = new Set(['javascript', 'c', 'c#', 'typescript', 'node.js', 'c++']);

const N = 2;

const N_element = [...st][N];

console.log(N_element); 

 
 
 
  
/*
run:
  
"c#"
  
*/

 



answered Jul 10, 2022 by avibootz

Related questions

2 answers 300 views
2 answers 280 views
1 answer 153 views
1 answer 184 views
1 answer 190 views
1 answer 207 views
...