This method adds two or more strings and returns a new single string.
Its syntax is as follows −
string.concat(string2, string3[, ..., stringN]);
string2...stringN − These are the strings to be concatenated.
Returns a single concatenated string.
Try the following example.
<html> <head> <title>JavaScript String concat() Method</title> </head> <body> <script type="text/javascript"> var str1 = new String( "This is string one" ); var str2 = new String( "This is string two" ); var str3 = str1.concat( str2 ); document.write("Concatenated String :" + str3); </script> </body> </html>
Concatenated String :This is string oneThis is string two.