A simple implementation of javascript multi line strings

  • 2020-06-03 05:50:40
  • OfStack

Use string +, or [].join (")

My colleague recommended this form


ExceptionDivHtml="<div class='gameItems'>\
 <div class='kreds_top_L'>\
  <span style='padding:0 10px;'><b>Current Balance:</b><font> </font> Credits</span>\
 </div>\
</div>";

Found support in the browser, the related writing is also very simple.

One problem is that when the string is compressed, the preceding space is also in the string, so it will not be compressed.

So for projects that don't need to be compressed, or where the compression requirements are less stringent, you can use the above approach and the code looks more structured and simple

This is the end of this article, I hope you enjoy it.


Related articles: