str.concat(string2, string3, string4,......, stringN)
Arguments: The arguments to this function are the strings that need to be joined together. The number of arguments to this function is equal to the number of strings to be joined together.
Return value: This function returns a new string that is the combination of all the different strings passed to it as the argument.
Below is an example of the concat() Method.
Example 1: In this example. we will merge Strings using concat() Method.
Geeks for Geeks
Example 2: In this example. we will merge Strings using concat() Method.
It is a great day.
The concat() function can also be used to concat strings stored in two or more variables. Also, spaces can also be added to the strings using the concat() function.
Example 3: In this example, we will see the concatenation of two strings stored in different variables also we will see how to include spaces between the strings.
Result without spaces: GeeksForGeeks Result with spaces: Geeks For Geeks
- Chrome 1 and above
- Edge 12 and above
- Firefox 1 and above
- Internet Explorer 4 and above
- Opera 4 and above
- Safari 1 and above
Please Login to comment...