Tutorials Point


  JavaScript Basics
  JavaScript Objects
  JavaScript Advanced
  JS Useful References
  JS Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Javascript String - concat() Method


previous next AddThis Social Bookmark Button


Advertisements

Description:

This method adds two or more strings and returns a new single string.

Syntax:

string.concat(string2, string3[, ..., stringN]);

Here is the detail of parameters:

  • string2...stringN : These are the strings to be concatenated.

Return Value:

Returns a single concatenated string.

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>

This will produce following result:

Concatenated String :This is string oneThis is string two.

To understand it in better way you can Try it yourself.



previous next Printer Friendly

Advertisements


  

Advertisements