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 user3309046 on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › join
Array.prototype.join() - JavaScript - MDN Web Docs
The join() method of Array instances returns a new string that is the concatenation of all elements in this array, separated by commas or a specified separator string. If the array has only one item, that item's stringification is returned without using the separator.
🌐
W3Schools
w3schools.com › jsref › jsref_join.asp
JavaScript Array join() Method
cssText getPropertyPriority() ... = fruits.join(" and "); Try it Yourself » · Share Link Copied · The join() method returns an array as a string....
🌐
SamanthaMing
samanthaming.com › tidbits › 15-4-ways-to-combine-strings
4 Ways to Combine Strings in JavaScript | SamanthaMing.com
Because it's working with array, it's very handy if you want to add additional strings. const instagram = '@samanthaming'; const twitter = '@samantha_ming'; const array = ['My handles are ', instagram, twitter]; const tiktok = '@samantaming'; array.push(tiktok); array.join(' '); // My handles are @samanthaming @samantha_ming @samanthaming
🌐
daily.dev
daily.dev › home › blog › webdev › join method javascript: faqs answered
Join Method JavaScript: FAQs Answered | daily.dev
May 25, 2026 - This is a neat trick to change how your string looks or to switch out separators. To join elements of an array into a single string in JavaScript, you use the join() method.
Top answer
1 of 6
140

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
30

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';
}

🌐
DEV Community
dev.to › jrcharney › split-and-join-the-dichotomy-of-strings-and-arrays-2hb
Split and Join: The Dichotomy of Strings and Arrays - DEV Community
December 19, 2022 - Strings and Arrays are like Yin and Yang. You use .split() to split an string into an array. You use .join() to join arrays into strings.
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › string-concat
3 Ways to Concatenate Strings in JavaScript - Mastering JS
You can concatenate strings in JavaScript using the `+` operator, the `Array#join()` function, or the `String#concat()` function. Here's what you need to know.
Find elsewhere
🌐
Code.mu
code.mu › en › javascript › manual › array › join
The join method - concatenation of array elements into a string in JavaScript
The join method concatenates all array elements into a string with the specified separator in JavaScript.
🌐
ReqBin
reqbin.com › code › javascript › 98ugueow › javascript-array-join-example
How do I join array elements in JavaScript?
To join JavaScript array elements in a string, you can use the array.join(separator) method. The array.join() method takes an array as input and a delimiter as a parameter and returns a string where all array elements are joined into a string ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › TypedArray › join
TypedArray.prototype.join() - JavaScript - MDN Web Docs
The join() method of TypedArray instances returns a new string that is the concatenation of all elements in this typed array, separated by commas or a specified separator string. If the typed array has only one item, that item's stringification is returned without using the separator.
🌐
Stack Abuse
stackabuse.com › how-to-join-concatenate-strings-in-javascript
How to Join/Concatenate Strings in JavaScript
March 27, 2023 - We've taken a look at how to concatenate strings in JavaScript using the + operator, the join() method of the Arrays class as well as the concat() method of the String class.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-array-join-method
JavaScript Array join() Method - GeeksforGeeks
January 16, 2026 - JS Tutorial · Web Tutorial · ... Last Updated : 16 Jan, 2026 · The JavaScript join() method is used to combine all elements of an array into a single string....
🌐
freeCodeCamp
freecodecamp.org › news › how-js-string-concatenation-works
JavaScript Concatenate Strings – How JS String Concatenation Works
May 7, 2024 - The concat() method is useful when ... the existing strings. The join() method allows you to concatenate an array of strings into a single string, with an optional separator between each array element....
🌐
GitHub
gist.github.com › adamjohnson › 11a399256ac783e9aa254b47c3a7fdad
Using the newline character with the .join() method in JavaScript to combine a string. · GitHub
Using the newline character with the .join() method in JavaScript to combine a string. - dot-join-with-newline-as-argument.js
🌐
Board Infinity
boardinfinity.com › blog › array-join-in-javascript
Array Join() in JavaScript | Board Infinity
January 2, 2025 - Mutability Misconception: Something that most developers get confused with is that join() does not adopt the first array. Separator Restrictions: With a separator any type of data can be handled but bad usage (like very long separators) makes the string illegible.
🌐
Futurestud.io
futurestud.io › tutorials › javascript-join-an-array-of-strings-to-a-single-string-value
JavaScript — Join an Array of Strings to a Single String Value
April 27, 2023 - The join method supports an optional, second argument which is used to concatenate the last item to the resulting string. import { Arr } from '@supercharge/arrays' const tags = ['JavaScript', 'Node.js', 'Strings'] Arr.from(tags).join() // 'JavaScript,Node.js,Strings' Arr.from(tags).join(', ') // 'JavaScript, Node.js, Strings' Arr.from(tags).join(', ', ', and') // 'JavaScript, Node.js, and Strings'