Carriage return | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 3

Carriage return

what is carriage return in js

5th Aug 2017, 11:18 AM
Darwin
Darwin - avatar
1 Réponse
0
Well you might want to forget about JScript for a while and think about Typewriters(The machines used to type on a paper) or Teletypes(The machine used with a Telegraph Line to do the same thing). Every Teletype uses a "Carriage" or a pointy thing at the end of a stick that keeps the track of where to print the next character. When you want to write a line on a teletype you have to point the Carriage to the beginning indent of the line and then start typing. when you want to get to the next line, you feed the paper and then stretch the carriage to the beginning indent. This act is called "Line Feed and Return Carriage". On it's own "Return Carriage" means to return the type head at the beginning indent and type over the line(which is messy to do on a paper) so, a Line Feed was added to Teletypes along with the "Return Carriage". This meant that every time there was a Carriage Return a line was fed to the machine, which was called "Enter Line" or "Enter". Many programming languages have been built on a Teletype(including BCPL and C) and just used that same convention, so it got stuck. In ASCII it was encoded as 2 characters 0x0D(Carriage Return) and 0x0A(Line Feed) combining which made End Of Line(EOL), This returns the cursor to beginning and adds a line. Now, on JScript. It is the very same thing like a Teletype only on a digital screen and acts the same way as it would have on a Teletype. It is used as a convention.
21st Jun 2020, 11:13 AM
Anubhav Mattoo
Anubhav Mattoo - avatar