Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

201
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda