Skip to content

Instantly share code, notes, and snippets.

@AnatoliyAkhmatov
Created July 12, 2021 04:10
Show Gist options
  • Save AnatoliyAkhmatov/206e0ba45038f0e0f0c4099aa4f33934 to your computer and use it in GitHub Desktop.
Save AnatoliyAkhmatov/206e0ba45038f0e0f0c4099aa4f33934 to your computer and use it in GitHub Desktop.
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
// https://example.com/path/to/page?color=purple&size=M&size=L
urlParams.get('color') // purple
urlParams.getAll('size') // ['M', 'L']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment