September 23, 2018
// for example URL: ianmcnally.me/index.php?view=article&id=18 // then window.location.search = "?view=article&id=18" const params = new URLSearchParams(window.location.search)
You get some really nice methods to call on it, like:
// window.location.search = "?view=article&id=18" params.get('id') // "18" // does it have a key: params.has('id') // true // setting a value params.set('id', '200') // ?view=article&id=200
Hey, I'm Ian. I build websites and write about what I learn as I go. Follow me on Twitter.