Skip to content

Support for JS Arrays “holes”, including the test suite #39

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Closed
MaxDesiatov opened this issue Aug 27, 2020 · 1 comment · Fixed by #41
Closed

Support for JS Arrays “holes”, including the test suite #39

MaxDesiatov opened this issue Aug 27, 2020 · 1 comment · Fixed by #41
Labels
enhancement New feature or request

Comments

@MaxDesiatov
Copy link
Contributor

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 j-f1 added the enhancement New feature or request label Aug 27, 2020
@kateinoigakukun
Copy link
Member

@j-f1 Thanks. Good catch!

No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants