KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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? (I am using Mozilla's Spidermonkey runtime.)
Tags (comma-separated)
Save Edits
Cancel