When iterating over an object's properties, is it safe to delete them while in a for-in loop?
For example:
for (var key in obj) {
if (!obj.hasOwnProperty(key)) continue;
if (shouldDelete(obj[key])) {
delete obj[key];
}
}
In many other languages iterating over an array or dictionary and deleting inside that is unsafe. Is it okay in JS?
FWIW, I am using Mozilla's Spidermonkey runtime.