-
Today's #WTF #JavaScript snippet. The following code loops infinitely. Apparently the
Set
iterator dynamically updates with new data added to theSet
. This applies *even* when you explicitly call.values()
before iterating. -
You have to do
Array.from(set.values())
to fully snapshot the state first, before you can safely iterate over it with mutations.