While your map example works (apart from the variable name new), I would say that's really a reduce solution.
map
new
reduce
arr.reduce((acc, item) => { if(!acc.includes(item)) { acc.push(item); } return acc; }, []);
I wouldn't use map for this, as it's not a straight, per item transform.
Took me a minute to figure out your fitler example :D
fitler
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
While your
map
example works (apart from the variable namenew
), I would say that's really areduce
solution.I wouldn't use map for this, as it's not a straight, per item transform.
Took me a minute to figure out your
fitler
example :D