Javascript: Is it safe to delete properties on an object being iterated with 'for' -


I am doing something like this:

  var myObj = {a: 1, b : 2, C: 3, D: 4}; (Var key in myObj) {if (some conditions) {delete (myObj [key]); }}   

This is what I have tried to do well in the samples, but I'm not sure that this can be unexpected behavior in certain scenarios / browsers.

Is it OK to repeat the object?

indicates that for..in forms the "next asset" Let's say the name of the next property of P. Obitz, whose [[enumerable]] attribute is correct if there is no such property, return (normal, V, empty) .

Since the concept "next asset" is well defined in the presence of mutation (although the recurrence order is not there)

is a corner case where is removed Uni-masks as a prototype property var obj = Object Create ({x: 1}); Obj.y = 2; Obj.x = 3; For (obj in var k) {if (k == 'y') {remove obj.x; } Alert (K); }

In this case, where you can repeat y and delete x , you can still type in X from the prototype, but if you repeat the x before, then y then you should not see the second x .

Comments