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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:37:46+00:00 2026-05-25T09:37:46+00:00

Today, I read this thread about the speed of string concatenation. Surprisingly, string concatenation

  • 0

Today, I read this thread about the speed of string concatenation.

Surprisingly, string concatenation was the winner:

http://jsben.ch/#/OJ3vo

The result was opposite of what I thought. Besides, there are many articles about this which explain oppositely like this.

I can guess that browsers are optimized to string concat on the latest version, but how do they do that? Can we say that it is better to use + when concatenating strings?


Update

So, in modern browsers string concatenation is optimized so using + signs is faster than using join when you want to concatenate strings.

But @Arthur pointed out that join is faster if you actually want to join strings with a separator.


Update – 2020
Chrome: Array join is almost 2 times faster is String concat +
See: https://stackoverflow.com/a/54970240/984471

As a note:

  • Array join is better if you have large strings
  • If we need generate several small strings in final output, it is better to go with string concat +, as otherwise going with Array will need several Array to String conversions at the end which is performance overload.

  • 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-25T09:37:47+00:00Added an answer on May 25, 2026 at 9:37 am

    Browser string optimizations have changed the string concatenation picture.

    Firefox was the first browser to optimize string concatenation. Beginning with version 1.0, the array technique is actually slower than using the plus operator in all cases. Other browsers have also optimized string concatenation, so Safari, Opera, Chrome, and Internet Explorer 8 also show better performance using the plus operator. Internet Explorer prior to version 8 didn’t have such an optimization, and so the array technique is always faster than the plus operator.

    — Writing Efficient JavaScript: Chapter 7 – Even Faster Websites

    The V8 javascript engine (used in Google Chrome) uses this code to do string concatenation:

    // ECMA-262, section 15.5.4.6
    function StringConcat() {
      if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
        throw MakeTypeError("called_on_null_or_undefined", ["String.prototype.concat"]);
      }
      var len = %_ArgumentsLength();
      var this_as_string = TO_STRING_INLINE(this);
      if (len === 1) {
        return this_as_string + %_Arguments(0);
      }
      var parts = new InternalArray(len + 1);
      parts[0] = this_as_string;
      for (var i = 0; i < len; i++) {
        var part = %_Arguments(i);
        parts[i + 1] = TO_STRING_INLINE(part);
      }
      return %StringBuilderConcat(parts, len + 1, "");
    }
    

    So, internally they optimize it by creating an InternalArray (the parts variable), which is then filled. The StringBuilderConcat function is called with these parts. It’s fast because the StringBuilderConcat function is some heavily optimized C++ code. It’s too long to quote here, but search in the runtime.cc file for RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) to see the code.

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

Sidebar

Related Questions

I read this article today http://dotnetslackers.com/articles/silverlight/Silverlight-3-and-the-Data-Form-Control-part-I.aspx about the use of the MVVM pattern within
Today I read this blog entry by Roger Alsing about how to paint a
Read this question today about safe and unsafe code I then read about it
I read this story on slashdot today where they announce a new parallel programming
I have used unions earlier comfortably; today I was alarmed when I read this
I read about the Conditional attribute today. According to MSDN: Applying ConditionalAttribute to a
Today I read this news: HP ran its webOS SDK on iPad 2, hopes
how are we today? I use this code to read an XML file and
Today I read abouts this on hacker news https://github.com/udibr/bitcoinApp which is an interesting app,
I read this story today on El Reg and I'm wondering if anyone in

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.