Trying to create an array out of existing one where all the consecutive items are merged:
[undefined, undefined, undefined] -> [undefined]
[undefined, 'item', undefined] -> [undefined, 'item', undefined]
[undefined, undefined, 'item'] -> [undefined, 'item']
I've tried [...new Set(temp)]
, where temp is the one of the above but that does not keep indexes.
EDIT: It would be beneficial if I could know number of items being merged into one when applicable
Please note the 2nd case where, despite duplicated items, array stays untouched