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 245 views
1 answer 288 views
1 answer 324 views
1 answer 337 views
1 answer 280 views
1 answer 194 views
1 answer 285 views
...