JavaScript URLSearchParams
https://test.com/?device_id=md00142&location=dhaka
https://test.com/device?device_id=md78547
const params = new URLSearchParams(window.location.search)
params.has('test')
const params = new URLSearchParams(window.location.search)
for (const param of params) {
console.log(param)
}
Other methods to alter the parameters, for use in other JavaScript running in the page (they do not change the URL):
append()to append a new parameter to the objectdelete()to delete an existing parameterset()to set the value of a parameter