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 element kinds: v8.dev/blog/elements-kinds
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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 element kinds: v8.dev/blog/elements-kindsWhy would setting the length of an array to
0
make itholey
? I would understand if you were to set the length to a value greater than its content, it would create aHOLEY_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, including0
.