arr.length → "4" // 4??? There are no elements in the array! arr[3] → "undefined" // 7 lines above, length was "0"!
The Top 10 Things Wrong with JavaScript
Richard Kenneth Eng
11423

It makes sense the array length is still 4. You did nothing to modify the actual array, only the values being stored within the array. If you did .pop() instead of that delete then the length would be 3.

The real strange thing you’re glossing over is that undefined is actually a value. It’s essentially a placeholder until other values get set. You can change the value of undefined if you aren’t in strict mode.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.