Create plain object from URLSearchParams Is there a shorter / cleaner way of creating a plain object from URLSearchParams than this:

const uri = new URL('https://tempuri.org/?token=secret&amp;test=true')
const result = {}
for (let p of uri.searchParams) {
  result[p[0]] = p[1]
}


Expected result:

{ token: 'secret', test: 'true' }
Since ES6 there is a cleaner solution with Object.fromEntries:
const url = 'https://tempuri.org/?token=secret&amp;test=true';
const params = new URL(url).searchParams;
Object.fromEntries(params);

It will output an object like this:
{ token: 'secret', test: 'true' }

See browser compatibility of Object.fromEntries on MDN. Basically all browsers and Node.js 12+ except Samsung Internet, Opera Android, and Internet Explorer. Time to say goodbye to the old browsers :)