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

291
Views
¿Por qué no se elimina el componente de consulta de URL?

Envuelvo el href a la URL e intento eliminar un componente, lo elimino con delete , pero el componente no desaparece. ¿Sabes por qué?

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

Intenté esto:

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

pero dice

TypeError no detectado: url.searchParams.filter no es una función


Probé ahora esta expresión, pero el filter no funciona, ¿tienes idea de por qué?

 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

El operador de delete elimina las propiedades de los objetos .

Está intentando eliminar una variable. Esto falla en silencio.

Para eliminar algo de un objeto URLSearchParams, use el método de delete :

 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!