Published Jun 21, 2021Updated Jun 28, 2023
Contribute to Docs

Concatenates or combines strings together.


string.concat(string_1, string_2, string_3);

Example 1

Concatenating a string:

console.log('Would you like a latte or '.concat('cappuccino?'));
// Output: Would you like a latte or cappuccino?

Example 2

Concatenating strings with the usage of variables:

const x = 'Would you like a latte or';
const y = 'cappuccino?';
console.log('Hey Bob! '.concat(x, ' ', y));
// Output: Hey Bob! Would you like a latte or cappuccino?

Codebyte Example

The following is runnable, and demonstrates the use of the .concat() method:


All contributors

Looking to contribute?

Learn JavaScript on Codecademy