In javascript, Line Feed and Carriage Return behaves similarly.
Which one to use and when?
OR
Can it be used alternatively?
Unicode Characters:
Line Feed: \u000A
Carriage Return: \u000D
Code:
<script>
alert("Hello \u000A World - <LF>");
alert("Hello \u000D World - <CR>");
</script>
/r/n. – akTed Jan 16 at 5:51\r\n, but that's a very specific context. In the context of an alert box and most other scenarios where you just want to create a new line, all you need is\n("newline"). There's no real reason to use a carriage return. There's no carriage or cursor to return or an arbitrary specification/outdated tradition that requires it. – Lèse majesté Jan 16 at 8:16alert("hello" + "\n" + "world")or simplyalert("hello\nworld"). As far as I know, that's valid in all browsers. I can't say which is better, but that's the way I've usually seen/done it. – akTed Jan 17 at 5:23