re: 13 useful JavaScript array tips and tricks you should know VIEW POST

TOP OF THREAD FULL DISCUSSION
re: FYI, #4 "Empty an array" will create a holey array. It's better to assign the value a new empty array [] rather than mutate the length. More on ele...
 

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.

code of conduct - report abuse