Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6902907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:51:27+00:00 2026-05-27T07:51:27+00:00

Being obsessed with neatness in Javascript lately, I was curious about whether there is

  • 0

Being obsessed with neatness in Javascript lately, I was curious about whether there is some type of common practice about how to deal with lines that span over 80 cols due to string length. With innerHTML I can mark line breaks with a backslash and indentation spaces won’t show up in the content of the element, but that doesn’t seem to go for eg. console.log().

Are there any conventions for this or should I just learn to live with lines longer than 80 cols? 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:51:28+00:00Added an answer on May 27, 2026 at 7:51 am

    There’s no universal convention. With modern high-res monitors you can easily fit 160 columns and still have room for IDE toolbars without needing to scroll, so I wouldn’t be concerned about sticking to 80 columns.

    Some people go out of their way to never have any line of code go past n columns, where n might be 80, or 160, or some other arbitrary number based on what fits for their preferred font and screen resolution. Some people I work with don’t care and have lines that go way off to the right regardless of whether it is due to a long string or a function with lots of parameters or whatever.

    I try to avoid any horizontal scrolling but I don’t obsess about it so if I have a string constant that is particularly long I will probably put it all on one line. If I have a string that is built up by concatenating constants and variables I will split it over several lines, because that statement will already have several + operators that are a natural place to add line breaks. If I have a function with lots of parameters, more than would fit without scrolling, I will put each parameter on a newline. For an if statement with a lot of conditions I’d probably break that over several lines.

    Regarding what you mentioned about innerHTML versus console.log(): if you break a string constant across lines in your source code by including a backslash and newline then any indenting spaces you put on the second line will become part of the string:

    var myString1 = "This has been broken\
                     into two lines.";
    // equivalent to
    var myString2 = "This has been broken                 into two lines.";
    // NOT equivalent to
    var myString3 = "This has been broken\
    into two lines.";
    

    If you use that string for innerHTML the spaces will be treated the same as spaces in your HTML source, i.e., the browser will display it with multiple spaces compressed down to a single space. But for any other uses of the string in your code including console.log() the space characters will all be included.

    If horizontal scrolling really bothers you and you have a long string the following method lets you have indenting without extra spaces in the string:

    var myString3 = "Hi there, this has been broken"
                  + " into several lines by concatenating"
                  + " a number of shorter strings.";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Being somewhat typographically obsessed, I am curious: what is the best way to present
Being really new to wx, I'm wondering if there is an IDE (especially for
Being new to JQuery and trying to understand all the posts about different ways
Being a developer born and raised on OO, I was curious to hear how
Being a softie, I'm currently fighting some hardware techies on a hardware detection mechanism.
Being concerned about Security, I change my DataBase password over a period of time.
Being faced with the question whether it's possible to choose #include s in the
Being not the best with javascript I am converting my file to coffeescript. Here
Being fairly new to JavaScript, I'm unable to discern when to use each of
Being new to wxWidgets I need some example code of how to get the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.