concat()
concatenates one or more strings
to another and returns the concatenated string.
This method does not change the existing strings.
concat() |
Yes | Yes | Yes | Yes | Yes |
stringObject.concat(string1, string2, ..., stringX);
Parameter | Description |
---|---|
string1, string2, ..., stringX | Required. The strings to join |
A new String containing the combined strings.
var stringValue = "hello ";
var result = stringValue.concat("world");
console.log(result); //"hello world"
console.log(stringValue); //"hello"
The code above generates the following result.
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.