Skip to main content
property URL.pathname

The pathname property of the URL interface is a string that represents the path of the URL.

Examples

Example 1

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

Example 2

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

Type

string

See

Back to top