JavaScriptEasy
How do you get the query string values of the current page in JavaScript?
By FrontendPro Editorial Team Updated 8/8/2026
#JavaScript
Answer
To get the query string values of the current page in JavaScript, you can use the URLSearchParams object. First, create a URLSearchParams instance with window.location.search, then use the get method to retrieve specific query parameters. For example:
js
const params = new URLSearchParams(window.location.search);
const value = params.get("language");
console.log(value);
