X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET 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 »


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

Internet Explorer Firefox Opera Google Chrome Safari

The concat() method is supported in all major browsers.


Syntax

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

Parameter Values

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

Return Value

Type Description
String A new string, containing the text of the combined strings

Technical Details

JavaScript Version: 1.2


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 BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook