• {string}

    获取及设置 URL 的主机部分。

    1. const myURL = new URL('https://example.org:81/foo');
    2. console.log(myURL.host);
    3. // 打印 example.org:81
    4. myURL.host = 'example.com:82';
    5. console.log(myURL.href);
    6. // 打印 https://example.com:82/foo

    分配给 host 属性的无效主机值将会被忽略。