


Remember that a string can contain a single character or none at all. The line feed will be detected and executed either way It does not matter what comes before or after \n, whether it's a character or an empty string. console.log('Gregor Clegane\nDunsen\nPolliver\nChiswyck')

Programmers often need to use \n line break to format text properly. Besides line feed, there is also indents (which you get from pressing Tab) and carriage return (Windows only). Although there are dozens of these characters, only a few of them are common in programming. \n is an example of an ** escape sequence**. For example, when the printer reaches the line feed, it pulls the paper up one line, and the text editor brings all subsequent text down one line as well. The device that outputs the corresponding text takes this character into account. Many editors can display these invisible characters, you can use this feature to see where they are (though it's only for display, these characters are invisible, they've no graphical representation): Anyone who has ever typed on a computer has used the line feed by clicking Enter. The Line Feed symbol is not something specific to programming. And since the number of keyboard characters is limited and they're all dedicated to very important things, special characters are entered using these escape sequences. There had to be a way of representing it using a keyboard. And it's also why this problem has arisen.

That's why line feed is just one character, just invisible. Why is it done in this way? \n is just a way to write a line break symbol.
#Escape sequences code
Below is code that returns the length of a string Proof: // We haven't studied it yet, but you should know the truth To the computer, this is no more than an invisible symbol to tell it to go to the next line. You may have initially thought it was a misprint, since there are two symbols - \ and n, but this isn't the case. It's often referred to as LF (Line Feed, sometimes as line break or newline) in documentation. console.log('- Are you hungry?\n- Aaaarrrgh!') You can do this with the new line symbol '\n'. In other words, it needs to put a line break after the question mark. We need to tell the interpreter to "press enter" as it were. The strings are written one after the other, it doesn't start a new line. Then you'll see: - Are you hungry?- Aaaarrrgh! If you print a string with this text: console.log('- Are you hungry?- Aaaarrrgh!') Inserts a backslash character in the text at this point.Imagine you want to print a dialogue between the Mother of Dragons and her child: - Are you hungry? Inserts a double quote character in the text at this point. Inserts a single quote character in the text at this point. Inserts a form feed in the text at this point. Inserts a carriage return in the text at this point. Inserts a newline in the text at this point. Inserts a backspace in the text at this point. The following table lists the escape sequences available in C programming language − Sr.No The following statement will not convey any meaning in C programming and it will be assumed as an invalid statement − char ch = '\1' Here, character n has been preceded by a backslash (\), it has special meaning which is a new line but keep in mind that backslash (\) has special meaning with a few characters only. In the following statement is a valid character and it is called a new line character − char ch = ' When a character is preceded by a backslash (\), it is called an escape sequence and it has a special meaning to the compiler. Many programming languages support a concept called Escape Sequence.
