Created
April 4, 2019 13:24
-
-
Save juliarose/98a54bc5ee0ea45f61493247532a2111 to your computer and use it in GitHub Desktop.
Simple method for getting the value of a URL parameter
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
/** | |
* Get a URL parameter | |
* @param {String} name - Name of parameter | |
* @returns {(String|null)} The value of parameter, if found | |
*/ | |
function getUrlParam(name) { | |
return new URL(location.href).searchParams.get(name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment