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

  • Home
  • SEARCH
  • 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 7490817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:46:22+00:00 2026-05-29T15:46:22+00:00

I have multiple strings as below – var str1 = this is a test

  • 0

I have multiple strings as below –

var str1 = "this is a test that goes on and on"+param1
var str2 = "this is also a test this is also"+param2+" a test this is also a test this is also a tes" 
var str3 = "this is also a test"

I’m assigning each string into its own var so as to keep the code readable and prevent the string values from trailing across the string. Also as I have read that the newline javascript character does not work in all browsers –
Creating multiline strings in JavaScript

I then concat the strings –

var concatStr = str1 + str2 + str3

and return the string concatenated value.

Is this an acceptable method of breaking up a large string into into its parts. Or can it be improved ?

  • 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-29T15:46:23+00:00Added an answer on May 29, 2026 at 3:46 pm

    There’s no need to assign each line to a different variable:

    var str1 = "this is a test that goes on and on"+param1 +
         "this is also a test this is also"+param2+
         " a test this is also a test this is also a tes" +
         "this is also a test";
    

    Personally, I’d do the following:

    var string = ['hello ', param1,
                  'some other very long string',
                  'and another.'].join(''); 
    

    For me, it’s easier to type out, and read.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the current script included below that goes into a file with extension
i have this code below that loops through a data structure builds up a
i have multiple strings containing a link like: <A HREF=http://www.testings2>testings2</A> <A HREF=http://www.blabla>blabla</A> <A HREF=http://www.gowick>gowick</A>
I have a string with a length that is a multiple of 8 that
I have a long string of comments that I'd like to split into multiple
I have multiple classes that all derive from a base class, now some of
I am writing a .py file that contains strings from multiple charactersets, including English,
I have a data set that looks like the below (the input). IR# CR#
Below is a quick example of what I am doing. Basically, I have multiple
I have a Winforms desktop application that is loading multiple MEF parts with 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.