nodejs string concatenation code example

Example 1: js string concatenation es6

let str=`JavaScript first appeared ${a+b} years ago. Wow!`;

Example 2: how to concatenate strings javascript

var str1 = "Hello ";
var str2 = "world!";
var res = str1.concat(str2);
// does not change the existing strings, but
// returns a new string containing the text
// of the joined strings.

Example 3: javascript string concat vs +

It is strongly recommended to use the string
concatenationoperators (+, +=) instead of String.concat
method for perfomance reasons

Example 4: js concatenate strings

const str1 = 'Hello';
const str2 = 'World';

console.log(str1 + str2);
>> HelloWorld

console.log(str1 + ' ' + str2);
>> Hello World

Example 5: string javascript concatenation

var dest = new String("");
    var src = new String("aze");
    var ar = new Array();
    ...
    ar.push(src);
    ar.push(src);
    ...
    dest = ar.join("");