const url = new URL('https://example.com/?firstkey=firstvalue&secondkey=secondvalue');
console.log(url.href);
// https://example.com/?a=hello&b=world
console.log(url.origin);
var obj = {};
for(const [key, value] of Array.from(url.searchParams.entries()))
{
obj[key] = value;
}
console.log(obj);
/*Object { firstkey: "firstvalue", secondkey: "secondvalue" }*/