When repeating over object properties, is it safe to delete them during the in-in cycle?
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 is unsafe. Is this normal in JS?
(I use the Mozilla Spidermonkey runtime.)
javascript object loops properties
Joe Shaw Aug 11 '10 at 21:37 2010-08-11 21:37
source share