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 191 views
2 answers 177 views
1 answer 103 views
1 answer 115 views
1 answer 130 views
...