Is it safe to delete elements in a Set while iterating with for..of?
问题 Is it specified that you can delete any element in an instance of Set while iterating using for..of and that you won't iterate more than once on an element you won't miss any other element that was in the set at the start of the iteration other than the ones you remove ? 回答1: Yes , it is perfectly fine to add elements and remove elements to a set while iterating it. This use case was considered and is supported in JavaScript 2015 (ES6). It will leave it in a consistent state. Note this also