JavaScript String concat() Method

Definition and usage

concat() The method concatenates two or more strings.

concat() The method does not change the existing string.

concat() The method returns a new string.

Instance

Example 1

Concatenate two strings:

let text1 = "sea";
let text2 = "food";
let result = text1.concat(text2);

Try it yourself

Example 2

Concatenate two strings:

let text1 = "Hello";
let text2 = "world!";
let result = text1.concat(" ", text2);

Try it yourself

Example 3

Concatenate three strings:

let text1 = "Hello";
let text2 = "world!";
let text3 = "Have a nice day!";
let result = text1.concat(" ", text2, " ", text3);

Try it yourself

Syntax

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

Parameter

Parameter Description
string1, string2, ... stringX Required. The string to be concatenated.

Return value

Type Description
String Contains the new string with the combined strings.

Description

Method concat() Converts all its parameters to strings (if necessary), then concatenate them in order to the string string Appending the string at the end, returning the concatenated string. Please note thatstring Itself is not modified.

String.concat() With Array.concat() It is very similar. Note that using the '+' operator for string concatenation is usually more convenient.

Browser support

concat() It is an ECMAScript1 (ES1) feature.

All browsers fully support ES1 (JavaScript 1997):

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support

Related Pages

JavaScript String

JavaScript String Methods

JavaScript String Search