JavaScript String concat() Method
THE WORLD'S LARGEST WEB DEVELOPER SITE

JavaScript String concat() Method

Example

Join two strings:

var str1 = "Hello ";
var str2 = "world!";
var res = str1.concat(str2);
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

The concat() method is used to join two or more strings.

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


Browser Support

Method
concat() Yes Yes Yes Yes Yes

Syntax

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

Parameter Values

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


Technical Details

Return Value: A new String, containing the text of the combined strings
JavaScript Version: ECMAScript 1

More Examples

Example 2

Join three strings:

var str1 = "Hello ";
var str2 = "world!";
var str3 = " Have a nice day!";
var res = str1.concat(str2, str3);
Try it Yourself »