How to iterate over a Set or Map in reverse order in javascript?

 

Iterate over a Map in Reverse Order in JavaScript
 

Given a JavaScript array and the task is to apply the map() method but on the reverse of the array efficiently.
 



var newSet = new Set([1,2,3,4,5]);
for (let num of Array.from(newSet ).reverse()) {
  console.log(num );
}

Tags:

Share:

Related posts