String.concat

concat — Combine a string with one or more strings into a new one.

Description

String.concat(string string, [string string, …])

Parameters

Name Description Type Default Optional
string string No
string, … string Yes

Return values

string primitive.

Examples

Example #1 – concat example

Combine two or more strings into a new one.

var text1 = 'Hello '; var text2 = 'World'; var text3 = text1.concat(text2); console.log(text3); // Will return Hello World.

You can also combine strings with the + operator.

var text1 = 'Hello '; var text2 = 'World'; var text3 = text1 + text2; console.log(text3); // Will return Hello World.

External references