With ES6, you can use

  • Template strings:

    var username = 'craig';
    console.log(`hello ${username}`);
    

ES5 and below:

  • use the + operator

    var username = 'craig';
    var joined = 'hello ' + username;
    
  • String's concat(..)

    var username = 'craig';
    var joined = 'hello '.concat(username);
    

Alternatively, use Array methods:

  • join(..):

    var username = 'craig';
    var joined = ['hello', username].join(' ');
    
  • Or even fancier, reduce(..) combined with any of the above:

    var a = ['hello', 'world', 'and', 'the', 'milky', 'way'];
    var b = a.reduce(function(pre, next) {
      return pre + ' ' + next;
    });
    console.log(b); // hello world and the milky way
    
Answer from typically on Stack Overflow
🌐
ZetCode
zetcode.com › javascript › add-string
JavaScript String Concatenation - Methods and Examples
October 18, 2023 - There are several ways of adding strings in JavaScript: ... The easiest way of concatenating strings is to use the + or the += operator.
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › String › concat
JavaScript String concat() - Concatenate Strings | Vultr Docs
November 14, 2024 - The concat() method in JavaScript is a straightforward approach to joining two or more strings into a single string. Valued for its simplicity and readability, concat() simplifies string operations by eliminating the need for more complex string ...
Discussions

How can I build/concatenate strings in JavaScript? - Stack Overflow
Does JavaScript support substitution/interpolation? Overview I'm working on a JavaScript project, and as it's getting bigger, keeping strings in good shape is getting a lot harder. I'm wondering w... More on stackoverflow.com
🌐 stackoverflow.com
Concatenate a string as many times the for loop runs
Tell us what’s happening: I want the for loop to run three times(or as many times is specified in the second parameter of the function). For some reason it is not working. I want to concatenate the string as many times… More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
May 30, 2020
append - How can I concatenate multiline string in javascript? - Stack Overflow
There are lots of results for the correct syntax for appending 's, however I am trying to find a solution where +this['name']+ values are included in the 's. firebug is display... More on stackoverflow.com
🌐 stackoverflow.com
Does JavaScript concatenate as string when adding a number to a string literal?
Those are "fancy quotes". " vs “. The correct is the former, you're using the latter. You may need to adjust the localization of your keyboard. More on reddit.com
🌐 r/learnjavascript
23
0
November 11, 2023
🌐
Attacomsian
attacomsian.com › blog › javascript-string-concat
4 ways to concatenate strings in JavaScript
July 3, 2021 - Because they're more readable with ... You write exactly how you want your string to appear. The join() method concatenates all elements in an array and returns a new string:...
Top answer
1 of 6
137

With ES6, you can use

  • Template strings:

    var username = 'craig';
    console.log(`hello ${username}`);
    

ES5 and below:

  • use the + operator

    var username = 'craig';
    var joined = 'hello ' + username;
    
  • String's concat(..)

    var username = 'craig';
    var joined = 'hello '.concat(username);
    

Alternatively, use Array methods:

  • join(..):

    var username = 'craig';
    var joined = ['hello', username].join(' ');
    
  • Or even fancier, reduce(..) combined with any of the above:

    var a = ['hello', 'world', 'and', 'the', 'milky', 'way'];
    var b = a.reduce(function(pre, next) {
      return pre + ' ' + next;
    });
    console.log(b); // hello world and the milky way
    
2 of 6
29

I'm disappointed that nobody in the other answers interpreted "best way" as "fastest way"...

I pulled the 2 examples from here and added str.join() and str.reduce() from nishanths's answer above. Here are my results on Firefox 77.0.1 on Linux.


Note: I discovered while testing these that if I place str = str.concat() and str += directly before or after each other, the second one always performs a fair bit better... So I ran these tests individually and commented the others out for the results...

Even still, they varied widely in speed if I reran them, so I measured 3 times for each.

1 character at a time:

  • str = str.concat(): 841, 439, 956 ms / 1e7 concat()'s
  • ............str +=: 949, 1130, 664 ms / 1e7 +='s
  • .........[].join(): 3350, 2911, 3522 ms / 1e7 characters in []
  • .......[].reduce(): 3954, 4228, 4547 ms / 1e7 characters in []

26 character string at a time:

  • str = str.concat(): 444, 744, 479 ms / 1e7 concat()'s
  • ............str +=: 1037, 473, 875 ms / 1e7 +='s
  • .........[].join(): 2693, 3394, 3457 ms / 1e7 strings in []
  • .......[].reduce(): 2782, 2770, 4520 ms / 1e7 strings in []

So, regardless of whether appending 1 character at a time or a string of 26 at a time:

  • Clear winner: basically a tie between str = str.concat() and str +=
  • Clear loser: [].reduce(), followed by [].join()

My code, easy to run in a browser console:

{
  console.clear();

  let concatMe = 'a';
  //let concatMe = 'abcdefghijklmnopqrstuvwxyz';

  //[].join()
  {
    s = performance.now();
    let str = '', sArr = [];
    for (let i = 1e7; i > 0; --i) {
      sArr[i] = concatMe;
    }
    str = sArr.join('');
    e = performance.now();
    console.log(e - s);
    console.log('[].join(): ' + str);
  }

  //str +=
  {
    s = performance.now();
    let str = '';
    for (let i = 1e7; i > 0; --i) {
      str += concatMe;
    }
    e = performance.now();
    console.log(e - s);
    console.log('str +=: ' + str);
  }

  //[].reduce()
  {
    s = performance.now();
    let str = '', sArr = [];
    for (let i = 1e7; i > 0; --i) {
      sArr[i] = concatMe;
    }
    str = sArr.reduce(function(pre, next) {
      return pre + next;
    });
    e = performance.now();
    console.log(e - s);
    console.log('[].reduce(): ' + str);
  }

  //str = str.concat()
  {
    s = performance.now();
    let str = '';
    for (let i = 1e7; i > 0; --i) {
      str = str.concat(concatMe);
    }
    e = performance.now();
    console.log(e - s);
    console.log('str = str.concat(): ' + str);
  }

  'Done';
}

🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-strings
JavaScript Strings - GeeksforGeeks
Concatenated String: JavaScript · 3. Escape Characters · We can use escape characters in string to add single quotes, dual quotes, and backslash. \' - Inserts a single quote \" - Inserts a double quote \\ - Inserts a backslash · JavaScript · const s1 = "\'GfG\' is a learning portal"; const s2 = "\"GfG\" is a learning portal"; const s3 = "\\GfG\\ is a learning portal"; console.log(s1); console.log(s2); console.log(s3); Output ·
Published   September 25, 2025
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › how-js-string-concatenation-works
JavaScript Concatenate Strings – How JS String Concatenation Works
May 7, 2024 - When coding in JavaScript, you may need to combine multiple strings to create a new, longer string. This operation is known as concatenation. In this article, you will learn five ways to concatenate strings in JavaScript. How to Concatenate Strings i...
🌐
Edureka
edureka.co › blog › javascript-string-concat
String Concatenation In JavaScript | String concat() Method | Edureka
January 9, 2025 - What is string concatenation in JavaScript? The string concatenation method takes multiple strings, merges them and returns a new single string.
🌐
SitePoint
sitepoint.com › blog › javascript › high-performance string concatenation in javascript
High-performance String Concatenation in JavaScript — SitePoint
November 5, 2024 - String concatenation is crucial in web applications, and JavaScript offers several ways to accomplish this, including the use of the “+” operator, the “+=” operator, the “concat” method, and joining an array of strings.
🌐
Useaxentix
useaxentix.com › blog › javascript › concatenate-strings-in-javascript
Concatenate Strings in JavaScript: Complete Guide
October 13, 2025 - You'll learn when to use each method, ... maintainable JavaScript code. String concatenation is the process of joining two or more strings together to create a new string....
🌐
Technource
technource.com › blog › string-concatenation-in-javascript
String Concatenation in JavaScript: Steps to Do It Easily
April 8, 2024 - String concatenation in JavaScript involves joining strings using the ‘+’ operator or template literals (‘${}’). It allows developers to create dynamic content and build user interfaces by combining text elements.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › javascript tutorial › javascript concatenate strings
JavaScript Concatenate Strings | Examples of Concatenate Strings
April 3, 2023 - The + operator is overloaded in javascript for string parameters and can be alternatively used for concatenating strings to obtain desired results. Similar to concat(), this manipulation also begins by converting the objects to their string format if they are not.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-concatenate-strings-in-javascript
Concatenation of Strings in JavaScript - GeeksforGeeks
January 17, 2026 - String concatenation is the process of joining two or more strings into a single string. JavaScript provides simple and flexible ways to combine strings for display, logging, or data manipulation.
🌐
Favtutor
favtutor.com › articles › concatenate-strings-javascript
Concatenate Strings in JavaScript (3 Easy Methods)
December 15, 2023 - Let’s check out various methods for how to do it in JavaScript: The first method of concatenating the string is by using the “+” operator. It is one of the simplest and most commonly used methods.
🌐
Copahost
copahost.com › home › concatenate strings in javascript: quick guide
Concatenate strings in Javascript: Quick guide - Copahost
May 31, 2020 - We concatenated these three variables into a string using the (+) sign. The result of this concatenation is also a string, i.e “string100true”. Remember, In javascript, anything concatenated with a string is always a string.
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Concatenate a string as many times the for loop runs - JavaScript - The freeCodeCamp Forum
May 30, 2020 - Tell us what’s happening: I want the for loop to run three times(or as many times is specified in the second parameter of the function). For some reason it is not working. I want to concatenate the string as many times it runs in the for loop. Your code so far function repeatStringNumTimes(str, num) { var str1 = str ; if(num
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String
String - JavaScript | MDN
Some of the most-used operations on strings are to check their length, to build and concatenate them using the + and += string operators, checking for the existence or location of substrings with the indexOf() method, or extracting substrings with the substring() method.
🌐
Scaler
scaler.com › home › topics › 4 ways to concatenate strings in javascript
4 Ways to Concatenate Strings in JavaScript - Scaler Topics
January 6, 2024 - The JavaScript String Concatenation method joins two or more strings without changing the existing strings, hence returning a new string. Learn the methods of String Concatenation here.