JS Built-ins
← Set47 / 85
SetforEachintermediate

Set forEach() β€” both args are the value

πŸ“– 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()

For Set, both the first and second callback arguments are the value.

Challenge: Verify that both args are the same value.

πŸ’‘ Hints (1)
  • β€’ Set.forEach callback: (value, value, set) β€” first two args are both the value