How to Change URL parameters in JavaScript?

Use URLSearchParams().

Example:

<script>
    var myUrl = 'localhost/index.php?product=shoes&category=all&size=big';
    myUrl = new URLSearchParams(myUrl);
    myUrl.set('category', 'shoes');

    console.log(myUrl.toString());
</script>