Changes

Jump to: navigation, search

JavaScript Operators

580 bytes added, 18:20, 20 April 2007
Operator Precedence
<td>,<td>Comma<td>Lowest</td>
<table>
 
Given the above table then clearly the following expression will multiply x by before adding the result to z because the multiplication operate has a higher precedence than the addition operator:
 
<pre>
 
k = z + x * y;
 
</pre>
 
The use of parentheses can be used to increase the precendence of part of an expression. For example if we put parentheses around the addition in the expression from above that part of the expression will be evaluated first. In the following example:
 
<pre>
 
k = (z + x) * y;
 
</pre>
 
z will be added to x and the result will then be multiplied by y.

Navigation menu