Web APIs
URL.origin
Returns the serialized origin; ordinary HTTPS origins include scheme, host and port.
Formal Syntax & Structure
javascript syntaxjavascript
url.originReturn Value
string
Serialized origin, or null string for opaque origin.
Working Example
Example Snippetjavascript
(async () => {const a=new URL("https://example.test/a"),b=new URL("https://example.test:8443/b");console.log(a.origin===b.origin,b.port);})()