Skip to content

Instantly share code, notes, and snippets.

@carlosascari
Last active February 2, 2022 23:31
Embed
What would you like to do?
Converts param/search string in url into object
/**
* Converts param/search string component from a url into an object
* Uses `location.search` as input string
*/
Object.assign.apply({}, location.search.substr(1).split('&').map(x => x.split('=').reduce((a, b) => { return { [a]: b } })))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment