Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我在 Javascript 中迭代 Array 或类似 Array 的对象时添加或删除元素,我是否需要考虑基础集合可能已更改或迭代器可能已失效?换句话说,是否有相当于Javascript 中 C++的Erase-remove 习语?
没有等价物,因为 JS 有垃圾回收,即在调用 remove 等价物后不需要erase在尾部调用。
erase
您可以在迭代时从数组中删除。