0

when I use webStrom2017 to console.log('123\r123'), it results in '123'. And I find if there are characters before and after \r. It will only output the following characters. Is this a BUG?

  • Good point. There seems to be a bug in webStorm for `\r`. See the answers to the question asked here: https://stackoverflow.com/q/39798849/4636715 – vahdet May 18 '18 at 14:42

1 Answers1

0

No, it is not a bug. Basically, \r means return cursor to the start of the row. That's why in windows to go to the new line you need \r\n, which means "go to start of the row, go to next row". This is the legacy of old computers with no UI.

So, when you print to terminal 123\r123 it means "write 123, go to start of the row and overwrite with 123".

However, nowadays, you can use either \n or \r\n in both UNIX-like OSes and windows.

Nestor Yanchuk
  • 1,186
  • 8
  • 10