DEV Community

Cover image for Url in Javascript
Dhanush N
Dhanush N

Posted on

3 2

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')
Enter fullscreen mode Exit fullscreen mode

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

console.log(url.toString())

// Output: https://github.com/DhanushNehru?tab=repositories
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay