DEV Community

Discussion on: 13 useful JavaScript array tips and tricks you should know

Collapse
 
antonioyon profile image
Antonio Yon

Why would setting the length of an array to 0 make it holey? I would understand if you were to set the length to a value greater than its content, it would create a HOLEY_ELEMENTS. Truncating should not have that same problem.

I would think the engine would continue to optimize for a PACKED_ELEMENTS Array if length were set to a value less than its current content, including 0.