r/learnjavascript • • May 14 '21

Remove Duplicate Value from array

Post image
234 Upvotes

89 comments sorted by

View all comments

20

u/slowthedataleak May 14 '21

Does this perform better than filter()?

78

u/StoneCypher May 14 '21

no, dramatically worse.

this is actually a terrible approach, and a big part of the reason why you shouldn't learn javascript from memes by dev.to spammers on reddit

2

u/amoliski May 14 '21

It's only terrible if you care about performance. If you do the operation a single time in response to a user clicking a button, who cares if it takes 0.01s longer to complete?

It's a bit more readable than the faster filter method, and that by itself has some value.