Skip to main content
method URL.toJSON
URL.toJSON(): string

The toJSON() method of the URL interface returns a JSON representation of the URL.

Examples

Example 1

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

Return Type

string

See

Back to top