Calls a callback function once for each key-value pair present in the Set object, in insertion order.
forEach(callback, thisArg?)
callback function(value, key, set)
A function that accepts up to three arguments: the value of the current element, the key of the element (which is the same as value), the original set. It is called one time for each element of the set.
thisArg optional
An object to which the this keyword is bound in the callback function. If omitted, undefined is used as the this value.
forEach is useful for performing side-effects with set elements.
let s = new Set()
s.add("first").add("second")
s.forEach((value) => print(`${value}`))
first
second