-
Notifications
You must be signed in to change notification settings - Fork 7
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
How to deal with empty items #6
Comments
It’s intentional from array spread, as in most new array methods, to pretend sparse arrays don’t exist, and to treat them as undefined as well. |
Can you specify which array methods? As far as I know, for every array method, the predicate is skipped when the item is empty. That would be option 3 here. |
Very interesting... So I checked the "new array methods"
So at least I feel And if someone really want treat empty items as |
@hax As the semantic of |
[optimize] add Mutation notice in ReadMe
@TechQuery Ideally no one should use arrays with empty slots anymore. It's unclear whether empty slots have different meaning with intentional |
What
[1, , 2, , , 2, 1].unique()
should return?At least there are three options:
undefined
, so returns[1, undefined, 2]
.This matches what
[...new Set(arr)]
do as README, but I suppose it's not intentional. Note ifunique(f)
,f
would be called on every empty items asundefined
, (or called with no param?) (To avoid runtime error, iff
is a key, I guess it should be treat asx => x?.[key]
)[1, , 2, , , ,]
[1, 2]
Personally I prefer the last option.
The text was updated successfully, but these errors were encountered: