Concatenation

Assignment Operators

To concatenate is to add the value of the right operand to the value of the left operand and the result is assigned to the left operand. Phew! did you get all of that?

Operands

Maybe this is a good time to answer the question "What is an operand?"

Binary Operators

You can have an expression Operand1 Operator Operand2. Operand1 is the left operand, Operand2 is the right operand, and both are separated by an Operator, which tells you what to do with them both.

Unary Operators

Or you can have an expression Operator Operand, or Operand Operator. An example of this Operator is the increment or decrement, such as X++ or --X.

Concatenate Strings

An example of concatenating two strings:

//declare variables
	var strQuote1, strQuote2, strQuote;
	//assign values
	strQuote1="<b class=orange>To be</b> ";
	strQuote2="<b class=yellow>or not to be,</b> ";

//concatenate strings
	strQuote=strQuote1+strQuote2;
	document.write(strQuote);
	strQuote="<br />" + strQuote + "<b class=blue>that is the question.</b><br /><br />";
	document.write(strQuote);

The actual result:


Strings and Integers

Loosely Typed

JavaScript is a "loosely typed language" which means you can use variables without declaring their type first. What this means is that JS figures out what your variable is by the way you use it in your program. Integers are something you would perform math on. String numbers are not. Below is an example.