Skip to main content
property URL.origin

The origin property of the URL interface is a string that represents the origin of the URL, that is the URL.protocol, URL.host, and URL.port.

Examples

Example 1

const myURL = new URL('https://foo.example.org/bar');
console.log(myURL.origin);  // Logs "https://foo.example.org"

Example 2

const myURL = new URL('https://example.org:8080/foo');
console.log(myURL.origin);  // Logs "https://example.org:8080"

Type

string

See

Back to top