Last active
May 19, 2020 18:18
-
-
Save ahsquared/ea12db0011ae897f85ec2de4e872b132 to your computer and use it in GitHub Desktop.
Quick way to get query params in ES6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qp =()=> window.location.search.substr(1).split('&').reduce( (a, c) => Object.assign(a, (c.indexOf('=') !== -1 ? c : `${c}=`).split('=').reduce( (a, c) => ({[a]: c})) ) ,{}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This now handles query params with no value