You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Not entirely sure how this should be handled, but JS Arrays support “holes”, where
[1,,3]
creates an array without anything at index1
. From the outside, that index appears to containundefined
, but array methods likemap
andforEach
skip over those indices while iterating, andflat
removes them, changing the indices of everything that comes after the hole. You can tell the difference between a hole and anundefined
value with eitherindex in array
orarray.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)
The text was updated successfully, but these errors were encountered: