JSFiddle - React, Tailwind, and code Playground
HTML
<textarea rows="5" cols="40" id="output" style="width:480px;height:100px;"></textarea>
JavaScript
var output = document.getElementById("output");
function trace(msg) {
output.value += msg + '\n';
}
var url = document.createElement("A");
url.href = "http://stackoverflow.com/question?hello=world#foo";
trace('// expexted: "stackoverflow.com", "/question"');
trace('// got: "' + url.hostname + '", "' + url.pathname + '"');
trace('')
url.hash = "bar";
url.search = "a";
url.protocol= "p";
url.host= "h";
url.port= "po";
url.pathname= "pathname";
trace('// expexted: "http://stackoverflow.com/question#bar"');
trace('// got: "' + url.href + '"');