const url = new URL(
"https://developer.mozilla.org/en-US/docs/Web/API/URL/hostname",
);
console.log(url.hostname); // Logs: 'developer.mozilla.org'
url.hostname = "你好.com";
console.log(url.hostname); // Logs: 'xn--6qq79v.com'URL: hostname property / notebook
URL: hostname property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.