On the URL Method of Vanilla JS

So recently I’ve discovered a weird construct in Vanilla JS that I haven’t seen before: the URL method. It looks like something like this: 1 2 3 4 5 const url = new URL(`${covalentAPI}${APIEndpoint}/`); url.search = new URLSearchParams({ key: APIKEY, tickers: tickers }) So after googling a little bit, I figured out what it does. URL method The URL method creates a new URL object. You can think of an URL object as a more convenient way of extracting and using different parts of URLs. The URL object has the following attributes: ...

December 13, 2021 · 2 min · Lei