Skip to content

Instantly share code, notes, and snippets.

@fayazara
Created November 13, 2019 07:27
Show Gist options
  • Save fayazara/ffaa9878b25e8e33b7aeb189af754173 to your computer and use it in GitHub Desktop.
Save fayazara/ffaa9878b25e8e33b7aeb189af754173 to your computer and use it in GitHub Desktop.
Get Query parameter from Current URL using vanilla.js
let urlParams = new URLSearchParams(window.location.search.substring(1));
let value = urlParams.get("query");
/*
Example URL - https://example.com?name=John
console.log(urlParams.get("name"));
"John will be printed in log"
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment