If I have a title with multiple consecutive spaces, document.title returns a string with a single space for each such space combo.
Example:
<title>[ ]</title> - HTML
"[ ]" - document.title
See also image below.
Question - how to get the raw string as it's defined in the HTML document? This caused a bug in one of my scraping scripts where a title should match some other element.

document.getElementsByTagName('title')[0].innerHTML? I don't know why this works, but it does...document.getElementsByTagName('title')[0].innerHTMLis just awful code. And don't use.innerHTMLwhen the string doesn't contain any HTML.