Instance of concat method for JavaScript string object (used to concatenate two or more strings)

  • 2020-03-30 04:06:33
  • OfStack

JavaScript concat method

Concat method concatenates two or more strings with the syntax as follows:

str_object.concat(str1, str2, ...)

Str_object is the first string to concatenate, str1 is the second string to concatenate, str2 is the third string to concatenate, and so on. At least one str1 is required.

Concat instance

<script language="JavaScript">
var str = "www";
var str1 = ".";
var str2 = "jb51";
var str3 = ".";
var str4 = "net";
document.write( str.concat(str1, str2, str3, str4) );

Run the example and output:
(link: #)
Tip: it is often easier to concatenate strings using the + operator, see: JavaScript operators.

Related articles: