EN
TypeScript - string newline character
0 points
In this short article, we would like to answer what is the newline character symbol in string in TypeScript.
Quick solution:
Use
\n
as a newline character.
xxxxxxxxxx
1
const text: string = '123\n456\n789'; // \n used as newline character
2
3
console.log(text); // 123
4
// 456
5
// 789
Notes:
- TypeScript newline character is platform independed,
- but, when we work on a text recived from the outside (people create content, application exchange data with endpoints), we need to know what newline character was used or use some techniques do deal with that text - check the article from the See also section below.