String.prototype.concat
Concatenates the string arguments to the calling string and returns a new string
Syntax
string.concat(...strings)Parameters
| Parameter | Type | Description |
|---|---|---|
| strings | string[] | Strings to concatenate to this string |
Return Value
A new string containing the combined text
Examples
const hello = 'Hello';
console.log(hello.concat(' ', 'World')); // 'Hello World'const a = 'foo';
const b = a.concat('bar', 'baz');
console.log(b); // 'foobarbaz'// Template literals are preferred over concat:
const name = 'World';
console.log(`Hello ${name}`); // 'Hello World'Understanding String.prototype.concat
The String.prototype.concat method in JavaScript concatenates the string arguments to the calling string and returns a new string. It belongs to the String object and is one of the most widely used methods for working with string values in modern JavaScript and TypeScript applications.
The method signature is string.concat(...strings). It accepts 1 parameter: strings. When called, it returns a new string containing the combined text. Understanding when and how to use concat() helps you write more expressive, readable code.
Common use cases for String.prototype.concat include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like array-concat, string-slice, string-repeat, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for String.prototype.concat is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
Array.prototype.concatMerges two or more arrays into a new array without changing the existing arrays
String.prototype.sliceExtracts a section of a string and returns it as a new string, without modifying the original string
String.prototype.repeatConstructs and returns a new string which contains the specified number of copies of the string on which it was called
More String Methods
Other methods in the String object
Related Tools
More String Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.