Support for JS Arrays “holes”, including the test suite
MaxDesiatov opened this issue · comments
Not entirely sure how this should be handled, but JS Arrays support “holes”, where [1,,3]
creates an array without anything at index 1
. From the outside, that index appears to contain undefined
, but array methods like map
and forEach
skip over those indices while iterating, and flat
removes them, changing the indices of everything that comes after the hole. You can tell the difference between a hole and an undefined
value with either index in array
or array.hasOwnProperty(index)
.
I think it’s perfectly fine to simply say that holes are not handled properly since they’re quite rare in practice but I wanted to make sure this language quirk wasn’t missed.
Originally posted by @j-f1 in #38 (comment)
@j-f1 Thanks. Good catch!