String
String + /n
String + HTML
Array of Strings + .join('\n')
.nodeValue
Supported in effectively all browsers (since IE6+, Firefox 2+, Chrome 1+ etc)
.textContent
Tends to have better performance because the text is not parsed as HTML but plain text. Moreover, using textContent can prevent XSS attacks.
.innerText
Represents the "rendered" text content of a node and its descendants.
.innerHTML
Potential security risk whenever you use innerHTML to set strings over which you have no control.
Method:
CSS white-space Settings:
white-space: normal;
white-space: nowrap;
white-space: pre;
white-space: pre-wrap;
white-space: pre-line;