Safe code for new Set() may look like:
let items = []; for (let item of set) if (isBad(item)) items.push(item); for (let item of items) set.delete(item) Can I simplify code to:
for (let item of set) if (isBad(item)) set.delete(item); Safe code for new Map() may look like:
let keys = []; for (let [key, val] of map) if (isBadKey(key) || isBadValue(val)) keys.push(key); for (let key of keys) map.delete(key) Can I simplify code to:
for (let [key, val] of map) if (isBadKey(key) || isBadValue(val)) map.delete(key)