4 ms·
Actually, deleting items from array is usually done with `Array#splice`. Using `delete` operator only deletes a property, but doesn't update Array object's `len
by kangax 17y ago
Actually, deleting items from array is usually done with `Array#splice`. Using `delete` operator only deletes a property, but doesn't update Array object's `length`, and it is this `length` that matters when iterating over an array (with `for(;;)`); when appending to array (using `Array#push`), and in few other cases.
In other words:
var array = [1,2,3,4];
delete array[2];
array.length === 4; // length is still 4
array.join() === '1,2,,4'; // which can lead to these kind of unexpected results