JS Built-ins
← Set50 / 85
SetforEachbeginner

Set forEach() β€” insertion order

πŸ“– Usage Example
const s = new Set([1, 2, 3])
s.forEach(val => console.log(val))
// 1, 2, 3

Use Set.forEach() to execute a callback for each value in the set.

Set.prototype.forEach()

forEach visits values in insertion order.

Challenge: Verify that forEach processes values in insertion order.

πŸ’‘ Hints (1)
  • β€’ forEach visits values in insertion order, each unique value exactly once