Samples for URLSearchParams

Querystring API in Javascript.

CRUD Querystring Params

The URLSearchParams API allows us to take values from any string and amend, delete and add to it. View the source of this page to see the code.

                        var ipUrl = $("input#qs1").val();
                        const params = new URLSearchParams(ipUrl);
                        params.set('page', 3);


Working with current page URL and Querystring

It comes in handy with working with window.location and Click the button and watch the querystring

                        var ipUrl = window.location;
                        const params = new URLSearchParams(;
                        params.set('foo', 123);
                        params.set('bar', 'abc');
               = params.toString();