Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

199
Vistas
Different outcomes by using URLSearchParams and URL().searchParams

I'm missing something in understanding the difference of using URLSearchParams and URL().searchParams. My test code is (testing against localhost):

let w = new URLSearchParams(window.location).get('origin');

let y = (new URL(window.location)).searchParams.get('origin');

w returns http://localhost:5500

y returns null

So what is the difference as I understood that they should return the same value only difference how its defined.

URLSearchParams creates new URLSearchParams object instance.

As for URL - creates and returns a URL object referencing the URL specified using an absolute URL string, or a relative URL string and a base URL string.

Then by using Read only property searchParams Im accessing the same URLSearchParams object but form this property I cannot modify it just read it.

Can you please point me into direction of understanding the difference?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda