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 152 views
1 answer 185 views
1 answer 224 views
1 answer 238 views
1 answer 172 views
1 answer 112 views
1 answer 191 views
...