Friday, September 5, 2025
HomeLanguagesJavascriptTypeScript | String concat() Method

TypeScript | String concat() Method

The concat() is an inbuilt function in TypeScript which is used to add two or more strings and returns a new single string. 

Syntax:

string.concat(string2, string3[, ..., stringN]); 

Parameter: This method accept a single parameter as mentioned above and described below.

  • string2…stringN: This parameter holds the strings which will be concatenate.

Return Value: This method returns the concatenated string.

Below example illustrate the  String concat() method in TypeScriptJS:

Example 1: 

JavaScript




<script>
    // Original strings
    var str1 = new String('neveropen'); 
    var str2 = new String(' - Best Platform'); 
  
    // Combines the text of two strings and 
    // returns a new string.
    console.log("Concatenated String : " 
            + str1.concat(str2.toString()));
</script>


Output: 

Concatenated String : neveropen - Best Platform

Example 2: 

JavaScript




<script>
    // Original strings
    var str1 = new String('Geeks'); 
    var str2 = new String('for'); 
    var str3 = new String('Geeks'); 
  
    // Combines the text of two strings and 
    // returns a new string.
    var str = str2.concat(str3.toString())
    str = str1.concat(str.toString())
    console.log("Concatenated String : " + str);
</script>


Output: 

Concatenated String : neveropen
RELATED ARTICLES

Most Popular

Dominic
32269 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6638 POSTS0 COMMENTS
Nicole Veronica
11802 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11866 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7027 POSTS0 COMMENTS
Thapelo Manthata
6704 POSTS0 COMMENTS
Umr Jansen
6721 POSTS0 COMMENTS