Url in Javascript

In javascript you can easily create a new URL using the below code

const url = new URL(‘https://github.com/DhanushNehru’)
url.searchParams.set(‘tab’,’repositories’)

The url.searchParams.set is used to set param values to the url

console.log…


This content originally appeared on DEV Community and was authored by DHANUSH N

In javascript you can easily create a new URL using the below code

const url = new URL('https://github.com/DhanushNehru')
url.searchParams.set('tab','repositories')

The url.searchParams.set is used to set param values to the url

console.log(url.toString())

// Output: https://github.com/DhanushNehru?tab=repositories

This URL API is safely supported in all modern browsers.

Hope you learned something new. Thank you for reading ❤️

For more insights connect with me via Twitter & Github


This content originally appeared on DEV Community and was authored by DHANUSH N


Print Share Comment Cite Upload Translate Updates
APA

DHANUSH N | Sciencx (2022-07-25T18:14:15+00:00) Url in Javascript. Retrieved from https://www.scien.cx/2022/07/25/url-in-javascript/

MLA
" » Url in Javascript." DHANUSH N | Sciencx - Monday July 25, 2022, https://www.scien.cx/2022/07/25/url-in-javascript/
HARVARD
DHANUSH N | Sciencx Monday July 25, 2022 » Url in Javascript., viewed ,<https://www.scien.cx/2022/07/25/url-in-javascript/>
VANCOUVER
DHANUSH N | Sciencx - » Url in Javascript. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/07/25/url-in-javascript/
CHICAGO
" » Url in Javascript." DHANUSH N | Sciencx - Accessed . https://www.scien.cx/2022/07/25/url-in-javascript/
IEEE
" » Url in Javascript." DHANUSH N | Sciencx [Online]. Available: https://www.scien.cx/2022/07/25/url-in-javascript/. [Accessed: ]
rf:citation
» Url in Javascript | DHANUSH N | Sciencx | https://www.scien.cx/2022/07/25/url-in-javascript/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.