Open In App
Related Articles

TypeScript | String concat() Method

Improve Article
Improve
Save Article
Save
Like Article
Like

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('GeeksforGeeks'); 
    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 : GeeksforGeeks - 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 : GeeksforGeeks

Last Updated : 18 Jun, 2020
Like Article
Save Article
Similar Reads
Related Tutorials