javascript get current url parameter value by name code example
Example 1: get parameter from the actual url javascript
// https://testsite.com/users?page=10&pagesize=25&order=asc
const urlParams = new URLSearchParams(window.location.search);
const pageSize = urlParams.get('pageSize');
Example 2: js check for url parameter
const params = new URLSearchParams(window.location.search);
// Check if we have the param
if (params.has("myParam")) {
console.log("Yep! We have it. Value is: " + params.get("myParam"));
} else {
console.log("The param myParam is not present.");
}