Javascript - String concat() Method

The concat() method can join two or more strings together.

Description

The concat() method can join two or more strings together.

This method does not change the existing strings, it returns a new string containing the text of the joined strings.

Syntax

string.concat(string1,string2, ...,stringX)

Parameter Values

Parameter RequireDescription
string1, string2, ..., stringX Required. The strings to be joined

Return

A new String, containing the text of the combined strings

Demo

//Join two strings:
var str1 = "Hello ";
var str2 = "world!";
var res = str1.concat(str2);
console.log(res);//  ww w . j  a  va2 s.co  m
//Join three strings:
var str3 = " Have a nice day!";
var res = str1.concat(str2, str3);
console.log(res);

Result