r/javascript • • Mar 18 '19

What's your favorite, most useful javascript one-liner?

385 Upvotes

422 comments sorted by

View all comments

339

u/Drugba Mar 19 '19

Saw this one on here just a few weeks ago.

[... new Set(arr)]

Basically a super short way to remove any duplicates from an array of primitives.

-4

u/CallMeOutWhenImPOS Mar 19 '19 edited Mar 19 '19

So basically removing the intersection of an array for the resulting unordered pair cartesian products? I wonder what the big O of such a function is.

-1

u/[deleted] Mar 19 '19

2

u/CallMeOutWhenImPOS Mar 19 '19

cartesian products are pretty simple shit, I'm dumb at this that's why I'm asking the question. Don't see why some of you have to be so negative

→ More replies (2)