-
-
Notifications
You must be signed in to change notification settings - Fork 57
Fix invalid array termination for null and undefined #38
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems legit 👍
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.
Do present test cases handle this quirk adequately or is there anything else you'd like to be covered in the test suite?
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.
No description provided.