const url = new URL("https://example.com?foo=1&bar=2");
const params = new URLSearchParams(url.search);
// Add a second foo parameter.
params.append("foo", 4);
console.log(params.getAll("foo")); // ["1", "4"]URLSearchParams: getAll() method / notebook
URLSearchParams: getAll() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.