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

205
Views
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
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!