const anchor = document.createElement("a");
console.log(anchor.href); // ""HTMLAnchorElement: href property / notebook
HTMLAnchorElement: href property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
anchor.href = "";
console.log(anchor.href); // "https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/href"anchor.href = "../../..";
console.log(anchor.href); // "https://developer.mozilla.org/en-US/docs/"console.log(anchor.getAttribute("href")); // "../../.."anchor.href = "https://example.com/path";
console.log(anchor.href); // "https://example.com/path"anchor.href = "https://";
console.log(anchor.href); // "https://"