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 150 views
1 answer 183 views
1 answer 222 views
1 answer 236 views
1 answer 171 views
1 answer 108 views
1 answer 187 views
...