• {string}

    获取及设置 URL 的协议部分。

    1. const myURL = new URL('https://example.org');
    2. console.log(myURL.protocol);
    3. // 打印 https:
    4. myURL.protocol = 'ftp';
    5. console.log(myURL.href);
    6. // 打印 ftp://example.org/

    分配给 protocol 属性的无效协议值将会被忽略。