Docs

URL.prototype.protocol

The protocol scheme of the URL, including the trailing colon.

Example

let url = new URL("https://example.com")
url.protocol
"https:"
let url = new URL("ftp://example.com")
url.protocol
"ftp:"
let url = new URL("https://example.com")
url.protocol = "http:"
url.href
"http://example.com/"