The concat() method can join two or more strings together.
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.
string.concat(string1,string2, ...,stringX)
Parameter | Require | Description |
---|---|---|
string1, string2, ..., stringX | Required. | The strings to be joined |
A new String, containing the text of the combined strings
//Join two strings: var str1 = "Hello "; var str2 = "world!"; var res = str1.concat(str2); console.log(res);/*from w w w . j av a 2 s . c om*/ //Join three strings: var str3 = " Have a nice day!"; var res = str1.concat(str2, str3); console.log(res);