- Instant help with your JavaScript coding problems

Get parameter from URL in JavaScript

How to get parameter from URL in JavaScript?
// https://testsite.com/users?page=10&pagesize=25&order=asc
const urlParams = new URLSearchParams(window.location.search);
const pageSize = urlParams.get('pageSize');

The URLSearchParams interface defines utility methods to work with the query string of a URL. The URLSearchParams.get() returns the first value associated with the given search parameter.

Share "How to get parameter from URL in JavaScript?"