Escape sequences are also useful for situations where you want to use characters that can’t be typed using a keyboard. Here are some other most commonly used escape sequences.
\nis replaced by the newline character
\tis replaced by the tab character
\ris replaced by the carriage-return character
\bis replaced by the backspace character
\\is replaced by a single backslash (
Here’s an example to clarify the how escape sequences actually works:
var str1 = "The quick brown fox \n jumps over the lazy dog."; document.write("<pre>" + str1 + "</pre>"); // Create line break var str2 = "C:\Users\Downloads"; document.write(str2); // Prints C:UsersDownloads var str3 = "C:\\Users\\Downloads"; document.write(str3); // Prints C:\Users\Downloads