Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

285
Views
Why url query component is not removed?

I wrap the href to URL, and try to remove one component, remove with delete, but component does not disappear. Do you know why?

let url = new URL(window.location.href);
let p = url.searchParams['postId'+$(".selected").length];
delete p;
window.location = url.toString();

I tried this:

const filteredItems = url.searchParams.filter(key => url.searchParams[key] == postID);
let key = filteredItems.keys.first;
url.searchParams.delete(key);

but it says

Uncaught TypeError: url.searchParams.filter is not a function


I tried now this expression, but filter does not work, do you have any idea why?

function togglePost(postID) {
    let url = new URL(window.location.href);
    const filteredItems = Object.keys(url.searchParams).filter(key =>
        url.searchParams[key] == postID
    );
    let key = filteredItems.keys.first;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The delete operator deletes properties from objects.

You are trying to delete a variable. This fails silently.

To delete something from a URLSearchParams object, use the delete method:

let url = new URL('http://example.com/foo.cgi?a=1&b=2');
console.log(url.toString());
url.searchParams.delete('a');
console.log(url.toString());

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!