ES6 - concat ()

Cette méthode ajoute deux chaînes ou plus et renvoie une nouvelle chaîne unique.

Syntaxe

string.concat(string2, string3[, ..., stringN]);

Détails de l'argument

  • string2...stringN - Ce sont les chaînes à concaténer.

Valeur de retour

Renvoie une seule chaîne concaténée.

Exemple

var str1 = new String( "This is string one" );
var str2 = new String( "This is string two" );
var str3 = str1.concat( str2 );
console.log("str1 + str2 : "+str3)

Production

str1 + str2 : This is string oneThis is string two