![]() |
VOOZH | about |
The concat() method in TypeScript merges two or more strings into one new string. It takes multiple string arguments and concatenates them in the order provided, returning the combined result.
string.concat(string2, string3[, ..., stringN]); Parameter: This method accepts a single parameter as mentioned above and described below.
Return Value: This method returns the concatenated string.
The below example illustrates the String concat() method in TypeScriptJS:
Example 1: In this example we initializes two String objects str1 and str2, concatenates them using the concat method, converts str2 to a string explicitly, and prints the concatenated result.
Output:
Concatenated String: GeeksforGeeks - Best PlatformExample 2: In this example we initializes a string str1 with "GeeksforGeeks" and uses the concat method without arguments, resulting in a copy of str1. It then prints the concatenated string.
Output:
Concatenated String: GeeksforGeeks