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 7817325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:11:49+00:00 2026-06-02T06:11:49+00:00

I know you can concatenate a string like this in Javascript: str1 + str2;

  • 0

I know you can concatenate a string like this in Javascript:

str1 + str2;

Or like this:

[str1, str2].join('');

Why is there a function to do this, too?

str1.concat(str2)

Is it any faster? Just seems like more typing to me. My guess is that this was used before str1 + str2 was optimized. Would that be correct?

  • 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-06-02T06:11:50+00:00Added an answer on June 2, 2026 at 6:11 am

    The String.prototype.concat method is very generic (ECMA Standard 5.1 Edition / June 2011, pp.143-144):

    1. Call CheckObjectCoercible passing the this value as its argument.
    2. Let S be the result of calling ToString, giving it the this value as its argument.
    3. Let args be an internal list that is a copy of the argument list passed to this function.
    4. Let R be S.
    5. Repeat, while args is not empty

      a. Remove the first element from args and let next be the value of that element.

      b. Let R be the String value consisting of the characters in the previous value of R followed by the
      characters of ToString(next).

    6. Return R.

    Because it’s so generic it can be used on almost every object that has a ToString() method. See also the following note:

    NOTE:
    The concat function is intentionally generic; it does not require that its this value be a String object. Therefore it can be transferred to other kinds of objects for use as a method.

    So you can use String.prototype.concat.call(myObject,....);. Note that there’s also a Array.prototype.concat method, which is also very generic (p. 125).

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

Sidebar

Related Questions

I know that I can concatenate strings in Lua like so String = String
This is something I know can be done somehow , because I've done it
I know this can be done and i have seen it done using some
I am storing a concatenated string like this: echo json_encode($PostedDate.$Places.$Company.$Designation.$ProjectDetails.$DesiredCandidate.$HRName.$HRContact.$Email); I can split this
I would like to concatenate strings together to create a command string in a
I know you can do this, because I've seen it done once before, but
I would like to know if we can pass a database table as http
How can I concatenate an int (e.g: 4 ) and a string (e.g: @/12
In PHP, if I create a string like this: $str = bla bla here
I would like to know if there is a way to detect how 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.