JavaScript mendapatkan nama domain dari string

const url = 'https://www.mydomain.com/blog?search=hello&world';
const domain = (new URL(url)).hostname.replace('www.','');
Average Ant