X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

JavaScript String concat() Method

JavaScript String Reference JavaScript String Reference

Example

Join two strings:

var str1 = "Hello ";
var str2 = "world!";
var res = str1.concat(str2);

The result of res will be:

Hello world!

Try it yourself »

More "Try it Yourself" examples below.


Definition and Usage

The concat() method is used to join two or more strings.

This method does not change the existing strings, but returns a new string containing the text of the joined strings.


Browser Support

Method
concat() Yes Yes Yes Yes Yes


Syntax

string.concat(string1, string2, ..., stringX)

Parameter Values

Parameter Description
string1, string2, ..., stringX Required. The strings to be joined

Technical Details

Return Value: A new String, containing the text of the combined strings
JavaScript Version: 1.2


Examples

More Examples

Example 2

Join three strings:

var str1 = "Hello ";
var str2 = "world!";
var str3 = " Have a nice day!";
var res = str1.concat(str2,str3);

The result of res will be:

Hello world! Have a nice day!

Try it yourself »


JavaScript String Reference JavaScript String Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook