concat()
String
instance method
JS Home <<
JS Reference <<
String <<
concat()
Description
Returns a new string from the concatenation of two or more strings, leaving original strings unaffected.
- Any modifications to the new string have no affect on the strings it was created from.
- Any modifications to the old strings have no affect on the new string created from them.
Syntax
Signature | Description |
---|---|
aString.concat(string1, string2[, ..., stringN]) | Returns a new string from the concatenation of two or more strings, leaving original strings unaffected. |
Parameters
Parameter | Description |
---|---|
string1, string2[, ..., stringN | Strings to concatenate into a new string.
|
Examples
The code below creates two new strings and concatenates a third string with the other two.
// Create 2 string varibles.
var string1 = 'Mon,Tues,Wed,Thurs';
var string2 = 'Fri,Sat,Sun';
/*
string1 still holds value 'Mon,Tues,Wed,Thurs' after concat.
The alert just shows the returned concat result which is 'Mon,Tues,Wed,Thurs,Fri,Sat,Sun'.
*/
alert(string1.concat(',', string2));
Related Tutorials
JavaScript Basic Tutorials - Lesson 8 - Strings