Open
Description
What [1, , 2, , , 2, 1].unique()
should return?
At least there are three options:
- Treat empty items as
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]
) - Skip all empty items and keep them, so returns
[1, , 2, , , ,]
- Skip all empty items and drop them, so returns
[1, 2]
Personally I prefer the last option.