const searchParams = new URLSearchParams("c=4&a=2&b=3&a=1");
searchParams.size; // 4URLSearchParams: size property / notebook
URLSearchParams: size property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
[...new Set(searchParams.keys())].length; // 3const url = new URL("https://example.com?foo=1&bar=2");
if (url.searchParams.size) {
console.log("URL has search parameters!");
}