You can use a for…of loop to iterate through the elements of a Set.
const letters = new Set([“a”,“b”,“c”]); for (const x of letters) { // code block to be executed } |
You can use a for…of loop to iterate through the elements of a Map.
const fruits = new Map([ [“apples”, 500], [“bananas”, 300], [“oranges”, 200] ]); for (const x of fruits) { // code block to be executed } |