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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.