const url = new URL(
"https://developer.mozilla.org/en-US/docs/Web/API/URL/toString",
);
const json = url.toJSON();
console.log(json); // https://developer.mozilla.org/en-US/docs/Web/API/URL/toString
console.log(typeof json); // "string"URL: toJSON() method / notebook
URL: toJSON() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
console.log(JSON.stringify(url));