When you need to append one string on the end of another this is known as concatenation. In JavaScript this is achieved using + operator, or string operator. This concatenation can be achieved in a number of ways each has its own advantages.
The simplest means of string concatenation in JavaScript is
function concat1(){
var test1 = "Welcome to " + "TomRed.net";
alert(test1);
}
It is possible to mix of string literals and string variables, and you may concatenate as many literals and variables on the same line as you wish.
function concat2(){
var test2 = "Welcome to " + "TomRed.net" + "\n I hope this is useful.";
alert(test2);
}
In Test 3 and 4 below we use Add By Value to append the value of the variable to the string. In the first case it is a string variable name that is concatenated. In the second case we show that even though the + operator is also the addition symbol when used with strings it will not add the values in this case intValue + 50 does not return 60 as might be expect but returns 1050. These two numbers have been concatenated and not added together. If it was require to add the two values together you would place the inside parenthesis (intValue + 50) you would get the desired result.
function concat3(){
var name = "TomRed.net" _cke_saved_name = "TomRed.net";
var test3 = "Welcome to " + name;
alert(test3);
}
function concat4(){
var intValue = 10;
var name = "TomRed.net";
alert("Welcome to " + name + " : " + intValue + 50 );
}
function concat5(){
var intValue = 10;
var name = "TomRed.net";
alert("Welcome to " + name + " : " + (intValue + 50) );
}


