How to get hostname from URL in JavaScript

1 Answer

0 votes
const url = "https://www.seek4info.com/search.php?type=sites&order=rand&query=wordpress+hosting";
 
const urlobj = new URL(url);
 
console.log(urlobj.hostname );

 
 
 
/*
run:
 
www.seek4info.com
 
*/

 



answered May 23, 2021 by avibootz

Related questions

1 answer 240 views
1 answer 281 views
1 answer 321 views
1 answer 335 views
1 answer 275 views
1 answer 188 views
1 answer 283 views
...