Javascript Reference - JavaScript String concat() Method








concat() concatenates one or more strings to another and returns the concatenated string.

This method does not change the existing strings.

Browser Support

concat() Yes Yes Yes Yes Yes

Syntax

stringObject.concat(string1, string2, ..., stringX);

Parameter Values

Parameter Description
string1, string2, ..., stringX Required. The strings to join




Return Value

A new String containing the combined strings.

Example


var stringValue = "hello "; 
var result = stringValue.concat("world"); 
console.log(result); //"hello world" 
console.log(stringValue); //"hello" 

The code above generates the following result.

Example 2

The concat() method accepts any number of arguments:


var stringValue = "hello "; 
var result = stringValue.concat("world", "!"); 
        
console.log(result); //"hello world!" 
console.log(stringValue); //"hello" 

The original string is not changed.

The code above generates the following result.