<!-- JavaScript:Strings code snippet 2. -->
<!-- String concatenation using '+' or '+='. -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Code source: http://www.justfigures.co.uk/ -->
<!-- A resource for web developers using XHTML, CSS, JavaScript, PHP -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>View code snippet page</title>
</head>

<body>
<script language="JavaScript" type="text/javascript">
<!--
/* Concatenation using '+' */
// create a string primitive called 'myString' 
var myString="Value of 'adding' my two strings of numbers 12 and 8 using '+' is: ";
// create two string primitives of 'numbers' 
var myString1="12";
var myString2="8";
// concatenate the 3 strings using '+' 
document.write(myString+myString1+myString2);
document.write("<br />");

/* Concatenation using '+=' */
var myEfficientString="Value of 'adding' my two strings of numbers 6 and 14 using '+=' is: ";
myEfficientString+="6";
myEfficientString+="14";
document.write(myEfficientString);
// -->
</script>

</body>
</html>