Skip to content
New issue

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

By clicking “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? Sign in to your account

Fix invalid array termination for null and undefined #38

Merged
merged 2 commits into from
Aug 27, 2020

Conversation

kateinoigakukun
Copy link
Member

No description provided.

Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems legit 👍

@kateinoigakukun kateinoigakukun merged commit a1ec259 into master Aug 27, 2020
@kateinoigakukun kateinoigakukun deleted the fix/array-iterator branch August 27, 2020 12:26
@j-f1
Copy link
Member

j-f1 commented Aug 27, 2020

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.

@MaxDesiatov
Copy link
Contributor

Do present test cases handle this quirk adequately or is there anything else you'd like to be covered in the test suite?

@j-f1
Copy link
Member

j-f1 commented Aug 27, 2020

I don’t believe there are any tests that involve array holes in the current test suite so if we want to support it new tests would need to be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants