Furthermore, (unlike in the literature example), the third-level nested quote must be escaped in order not to conflict with either the first- or second-level quote delimiters. This is true regardless of alternating-symbol encapsulation. Every level after the third level must be recursively escaped for all the levels of quotes in which it is contained. This includes the escape character itself, the backslash (“\”), which is escaped by itself (“\\”).
For every sublevel in which a backslash is contained, it must be escaped for the level above it, and then all the backslashes used to escape that backslash as well as the original backslash, must be escaped, and so on and so forth for every level that is ascended. This is to avoid ambiguity and confusion in escaping.
document.write("<doc><head></head><body><p>Hello, this is the body of the document.");
document.writeln("</p>");
document.write("<p>A newline in HTML code
acts simply as whitespace, whereas a <br> starts a new line.");
document.write("</p></body></doc>\n");
eval('eval(\"eval(\\\"alert(\\\\\\\"Now I\\\\\\\\\\\\\\\'m confused!\\\\\\\")\\\")\")');
Note that the number of backslashes increase from 0 to 1 to 3 to 7 to 15, indicating a rule for successively nested symbols, meaning that the length of the escape sequences grows exponentially with quotation depth.