Last active
August 24, 2017 07:26
-
-
Save Bizunow/fbe3a5edcd9b88a63bf1aa0c1df8e3b8 to your computer and use it in GitHub Desktop.
[Get URL parametr] #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
// getUrlParam('http://test.com?a=1', 'a') // return 1 | |
function getUrlParam(urlString, param) { | |
const url = new URL(urlString); | |
return url.searchParams.get(param); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment