Javascript logo

Sometimes you need to get the parameters and values from the query string in your JavaScript/TypeScript applications. If you don't want to spend the time on making your own methods, you can use this one with URLSearchParams.

For example. the URL looks this way:

To extract the 'pollId' value you can use the code below:

const urlParams = new URLSearchParams(;
const pollId:number = parseInt(urlParams.get('pollId'))

As you can see, it's easy.