Created
March 9, 2018 07:34
-
-
Save YiqinZhao/69f05ed1a8eca67626d9fde5449d6d81 to your computer and use it in GitHub Desktop.
[Split URL Parameters] Simple code for URL parameters split. #web
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 result = window.location.href | |
.split('?')[1] | |
.split('&') | |
.map(v => v.split('=')) | |
.reduce((obj, v) => { obj[v[0]] = v[1]; return obj }, {}) | |
console.log(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment