String.prototype.concat()
Concatenates string arguments to the calling string and returns a new string.
Syntax
str.concat(...strings) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
strings | string | No | One or more strings (or values coerced to strings) to append. |
Returns
string — A new string combining the calling string and the arguments.
Examples
console.log('Hello'.concat(', ', 'world', '!'));
Output
Hello, world!
console.log(''.concat(1, 2, 3));
Output
123
Notes
The `+` operator or template literals are generally preferred and faster.
Non-string arguments are coerced to strings. Does not mutate the original.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 1.0 |
| firefox | 1.0 |
| safari | 1.0 |
| edge | 12 |
| node | 0.10 |