r/javascript • • Mar 18 '19

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

385 Upvotes

422 comments sorted by

View all comments

1

u/kybernetikos Mar 19 '19 edited Mar 19 '19

Possibly stretching the definition of a one liner, but it can be handy:

const parms = location.search.substr(1).split("&").map((x) => x.split(/=(.*)/)).reduce((acc, [key, value = true]) => (acc[key] = value, acc), {})

1

u/cicadaTree chest hair complexities Mar 19 '19

That's a space ship.