Last active
October 21, 2021 09:47
-
-
Save NaClYen/de4036bff89eddd644fb0d6094bb6df9 to your computer and use it in GitHub Desktop.
JS - url search params to dictionary
This file contains 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
let dict = Array.from(new URLSearchParams(window.location.search)).reduce( | |
(d, [k, v]) => { | |
d[k] = v; | |
return d; | |
}, | |
{} | |
); |
This file contains 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
const a = new URLSearchParams(window.location.search); | |
const b = Array.from(a); | |
const c = b.reduce((dict, [key, value]) => { | |
dict[key] = value; | |
return dict; | |
}, {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment