.concat()
Published Jun 21, 2021Updated Jun 28, 2023
Contribute to Docs
Concatenates or combines strings together.
Syntax
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:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.