const url = new URL(window.location.href);
url.searchParams.delete(query); // ?page=4 (here page and its value will be deleted);
window.history.pushState({ path: url.href }, '', url.href);
About
This app is about , how to add one or more query parameters in url.