I'm creating an HTML document object:
let newHTMLDocument = document.implementation.createHTMLDocument();
let html = `<!DOCTYPE html>
<html>
<head>
<title>Hello, world!</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>`;
newHTMLDocument.open();
newHTMLDocument.write( html );
newHTMLDocument.close();
console.log( String(newHTMLDocument) ); // [object HTMLDocument]
Instead of "[object HTMLDocument]," how can I convert newHTMLDocument into a string containing all of the HTML code, including the doctype and html tag?