Created
October 13, 2020 13:26
-
-
Save justforuse/9497845e03c0cc9fa11db3c636391bb1 to your computer and use it in GitHub Desktop.
Parse url search params by vanilla js
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
// Sometimes this should use location.href | |
let params = (new URL(document.location)).searchParams; | |
let name = params.get('name'); // is the string "Jonathan Smith". | |
let age = parseInt(params.get('age')); // is the number 18 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment