r/javascript • • Mar 02 '19

Useful javascript one-liners.

https://medium.com/@smellycode/js-one-liners-8bc0a6af2345?source=friends_link&sk=a9295a05aef9e514e137fca7eeb89cd1
344 Upvotes

96 comments sorted by

View all comments

6

u/Drugba Mar 03 '19

I absolutely love [...new Set(arr)] for removing dupes from an array of primitives. That being said, if I was using it in a shared codebase, I'd be sure to add a comment explaining it as I don't think it's super clear at first glance.

1

u/drowsap Mar 03 '19

Why not have it as a Set to being with instead of an array? If it’s the way that the data returns from the server, then dedupe there?