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 197 views
2 answers 185 views
1 answer 108 views
1 answer 120 views
1 answer 132 views
...