JavaScript concat() Method
Example
Concatenate two strings:
var str1 = "Hello ";
var str2 = "world!";
var n = str1.concat(str2);
n Output result:
Hello world!
Try it »
Definition and Usage
The concat() method is used to join two or more strings.
This method does not change the original string, but returns a new string that joins two or more strings.
Browser support





All major browsers support the concat() method
Syntax
string
.concat(
string1
,
string2
, ...,
stringX
)
Parameter value
| Parameters | Description |
|---|---|
| string1, string2, ..., stringX | Required. One or more string objects to be joined into a single string. |
Return Value
| Type | Description |
|---|---|
| String | A new string generated by concatenating two or more strings. |
Technical Details
| JavaScript version: | 1.2 |
|---|
More examples
Example 2
Concatenate 3 strings:
var str1="Hello ";
var str2="world!";
var str3=" Have a nice day!";
var n = str1.concat(str2,str3);
n Output result:
Hello world! Have a nice day!
Try it »
JavaScript String object