In [[Introducing JavaScript Variables]] we looked at the '=' assignent operator. This is the most basic of assignment operators and serves to simply assign a value to a variable. For example y = 10 assigns the value of 10 to a variable called y.  
 
In [[Introducing JavaScript Variables]] we looked at the '=' assignent operator. This is the most basic of assignment operators and serves to simply assign a value to a variable. For example y = 10 assigns the value of 10 to a variable called y.  
 
<google>ADSDAQBOX_FLOW</google>
 
<google>ADSDAQBOX_FLOW</google>
The '=' assignment operator does not make any changes to the value before it is assigned to the variable. A number of assignment operators are available, however, that perform arithmetic on the value before assigning it to the variable. These are essentially combined arithmetic and assignment operators. The most common operators of this type, and their "long hand" equivalents are shown below:
+
The '=' assignment operator does not make any changes to the value before it is assigned to the variable. A number of assignment operators are available, however, that perform arithmetic on the value before assigning it to the variable. These are essentially combined arithmetic and assignment operators. The most common operators of this type and their "long hand" equivalents are shown below:
    
<table border="1" cellspacing="0">
 
<table border="1" cellspacing="0">
 
== Arithmetic Operators ==
 
== Arithmetic Operators ==
   −
As one might expect, arithmetic operators perform mathematical calculations on values and variables. JavaScript arithmetic is comprised of expressions made up of an operator and values to the right and left of that operator (better known as ''operands''). For example in the ''expression'' z = x + y, the + is the ''arithmetic operator'', x and y are the ''operands'' and the = is the "assignment operator":
+
As one might expect, arithmetic operators perform mathematical calculations on values and variables. JavaScript arithmetic is comprised of expressions made up of an operator and values to the right and left of that operator (better known as ''operands''). For example in the ''expression'' z = x + y, the + is the ''arithmetic operator'', x and y are the ''operands'' and the = is the ''assignment operator'':
   −
The following example adds the first ''operand'' (2) to the second operand (5) and assigns the result (7) to the variable ''y''.
+
The following example adds the first operand (2) to the second operand (5) and assigns the result (7) to the variable ''y''.
       
</pre>
 
</pre>
   −
Arithmetic operatations can also be performed on variables:
+
Arithmetic operations can also be performed on variables:
    
<pre>
 
<pre>
 
</pre>
 
</pre>
   −
These operators can also be used to increment and decrement a value after an expression as been performed. Suppose you have a variable ''x'' which has been assigned a value of 5. You want to add the value of x to a variable called y and then decrement x by 1. One way to do this is as follows:
+
These operators can also be used to increment and decrement a value after an expression has been performed. Suppose you have a variable ''x'' which has been assigned a value of 5. You want to add the value of x to a variable called y and then decrement x by 1. One way to do this is as follows:
    
<pre>
 
<pre>
 
<th>Operator<th>Description<th>Example</th>
 
<th>Operator<th>Description<th>Example</th>
 
<tr>
 
<tr>
<td>==<td>Equal operator - retuns ''true'' if both operands are equal.<td>x == 6 returns ''true'' if x is 6</td>
+
<td>==<td>Equal operator - returns ''true'' if both operands are equal.<td>x == 6 returns ''true'' if x is 6</td>
 
<tr>
 
<tr>
 
<td>!=<td>Not-equal operator - returns ''true'' if operands are not equal.</td><td>x != 6  returns true if x is not 6</td>
 
<td>!=<td>Not-equal operator - returns ''true'' if operands are not equal.</td><td>x != 6  returns true if x is not 6</td>
 
In this example the output will read "Hello, John, how are you?"
 
In this example the output will read "Hello, John, how are you?"
   −
It is also important to understand that concatenation can handle variable types other than strings. For example, when the concatentation operator is used and it encounters a number it will convert that number to a string and join it to the string. For example:
+
It is also important to understand that concatenation can handle variable types other than strings. For example, when the concatenation operator is used and it encounters a number it will convert that number to a string and join it to the string. For example:
    
<pre>
 
<pre>
 
</pre>
 
</pre>
   −
will output the message "You are visitor number 10". Note, however, that when an expression contains only one type of operator (i.e only the + operator - see the "Operator Precedence" below for handling expressions with mixed operators) JavaScript evaluates the expression from left to right. So, if it encounters numbers before it encounters a string it will assume that it has found an arithmetic + rather than a string concatenation +. For example:
+
The above code will output the message "You are visitor number 10". Note, however, that when an expression contains only one type of operator (i.e. only the + operator - see the "Operator Precedence" below for handling expressions with mixed operators) JavaScript evaluates the expression from left to right. So, if it encounters numbers before it encounters a string it will assume that it has found an arithmetic + rather than a string concatenation +. For example:
    
<pre>
 
<pre>
 
</pre>
 
</pre>
   Exception encountered, of type "Error"
[2aade41c] /index.php?title=JavaScript_Operators&diff=7277&oldid=6949 Error from line 434 of /var/www/techotopia/includes/diff/DairikiDiff.php: Call to undefined function each()
Backtrace:
#0 /var/www/techotopia/includes/diff/DairikiDiff.php(544): DiffEngine->diag()
#1 /var/www/techotopia/includes/diff/DairikiDiff.php(344): DiffEngine->compareSeq()
#2 /var/www/techotopia/includes/diff/DairikiDiff.php(227): DiffEngine->diffLocal()
#3 /var/www/techotopia/includes/diff/DairikiDiff.php(721): DiffEngine->diff()
#4 /var/www/techotopia/includes/diff/DairikiDiff.php(859): Diff->__construct()
#5 /var/www/techotopia/includes/diff/DairikiDiff.php(980): MappedDiff->__construct()
#6 /var/www/techotopia/includes/diff/TableDiffFormatter.php(194): WordLevelDiff->__construct()
#7 /var/www/techotopia/includes/diff/DiffFormatter.php(140): TableDiffFormatter->changed()
#8 /var/www/techotopia/includes/diff/DiffFormatter.php(82): DiffFormatter->block()
#9 /var/www/techotopia/includes/diff/DifferenceEngine.php(881): DiffFormatter->format()
#10 /var/www/techotopia/includes/diff/DifferenceEngine.php(797): DifferenceEngine->generateTextDiffBody()
#11 /var/www/techotopia/includes/diff/DifferenceEngine.php(728): DifferenceEngine->generateContentDiffBody()
#12 /var/www/techotopia/includes/diff/DifferenceEngine.php(662): DifferenceEngine->getDiffBody()
#13 /var/www/techotopia/includes/diff/DifferenceEngine.php(632): DifferenceEngine->getDiff()
#14 /var/www/techotopia/includes/diff/DifferenceEngine.php(453): DifferenceEngine->showDiff()
#15 /var/www/techotopia/includes/page/Article.php(797): DifferenceEngine->showDiffPage()
#16 /var/www/techotopia/includes/page/Article.php(508): Article->showDiffPage()
#17 /var/www/techotopia/includes/actions/ViewAction.php(44): Article->view()
#18 /var/www/techotopia/includes/MediaWiki.php(490): ViewAction->show()
#19 /var/www/techotopia/includes/MediaWiki.php(287): MediaWiki->performAction()
#20 /var/www/techotopia/includes/MediaWiki.php(714): MediaWiki->performRequest()
#21 /var/www/techotopia/includes/MediaWiki.php(508): MediaWiki->main()
#22 /var/www/techotopia/index.php(41): MediaWiki->run()
#23 {main}