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

filter_none

edit
close

play_arrow

link
brightness_4
code

<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>

chevron_right


Output: 

Concatenated String : GeeksforGeeks - Best Platform

Example 2: 

JavaScript

filter_none

edit
close

play_arrow

link
brightness_4
code

<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>

chevron_right


Output: 

Concatenated String : GeeksforGeeks

full-stack-img




My Personal Notes arrow_drop_up

Small things always make you to think big

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.