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?