var str = "I learn JavaScript, ";
alert( str.concat( "number ", 1, " web scripting language" ) );
Tip: to piece together an array of strings, use the join() method instead.
alert( "I ".concat( "learn ", "JavaScript" ) );
var str = "I learn ";
// Take current value and add something to it:
str = str + "JavaScript";
alert( str );
... or the "concatenation assignment" operator (a plus and equal signs stuck together). var str = "I learn ";
str += "JavaScript"; // Same effect as above
alert( str );
$str = 'I ' . 'learn '; // concatenation
$str .= 'PHP'; // concatenation-assignment
echo $str; // -> 'I learn PHP'
Sister / opposite method: split() separates a string into an array, using the character(s) you pass as argument to break it up (returns single-element array with original string if it can't separate).