But newline \n, backspace \b, carriage return \r, and tab \t don't work.
Those characters are not treated in any special way in HTML, they are simply whitespaces. If you want to create a line break in HTML, you have to use the <br /> tag.
From the specification (emphasis mine):
This specification does not indicate the behavior, rendering or otherwise, of space characters other than those explicitly identified here as white space characters. For this reason, authors should use appropriate elements and styles to achieve visual formatting effects that involve white space, rather than space characters.
To be clear: This has nothing to do with JavaScript, only with how HTML works. Tiny example: Fiddle. I have a line break in my source code (that's the same as what would be created with document.write('Foo \n bar')), but the line break is not rendered in by the browser.
If you use alert or console.log instead of document.write you will see the actual generated string, because the string is not displayed in a HTML context.