Operators and Expressions:Operator Summary Table : Operator « Language Basics « JavaScript DHTML






Operators and Expressions:Operator Summary Table

  
<html>
<head>
<title>JavaScript Operators</title>
</head>
<body>
<h1>JavaScript Operators</h1>
<table BORDER="2" CELLPADDING="4" ALIGN="CENTER">
<tr><td>Category</td>
<td>Operator</td>
<td>Description</td>
<td>Usage Example</td>
<td>Value/Result</td></tr>
<tr><td>String</td>
<td>+</td>
<td>concatenation</td>
<td>&quot;Java&quot; + &quot;Script&quot;</td>
<td><script><!--
document.write("Java"+"Script")
// --></script>
</td></tr>
<tr><td ROWSPAN="10">Arithmetic</td>
<td>+</td>
<td>addition</td>
<td>3 + 3</td>
<td><script><!--
document.write(3+3)
// --></script>
</td></tr>
<tr><td ROWSPAN="2">-</td>
<td>subtraction</td>
<td>6 - 2</td>
<td><script><!--
document.write(6-2)
// --></script>
</td></tr>
<tr><td>unary negation</td>
<td>-4</td>
<td><script><!--
document.write(-4)
// --></script>
</td></tr>
<tr><td>*</td>
<td>multiplication</td>
<td>4 * 4</td>
<td><script><!--
document.write(4*4)
// --></script>
</td></tr>
<tr><td>/</td>
<td>division</td>
<td>15/5</td>
<td><script><!--
document.write(15/5)
// --></script>
</td></tr>
<tr><td>%</td>
<td>modulus</td>
<td>22%7</td>
<td><script><!--
document.write(22%7)
// --></script>
</td></tr>
<tr><td ROWSPAN="2">++</td>
<td>increment and then return value</td>
<td>x=4; ++x</td>
<td><script><!--
x=4
document.write(++x)
// --></script>
</td></tr>
<tr><td>return value and then increment</td>
<td>x=4; x++</td>
<td><script><!--
x=4
document.write(x++)
// --></script>
</td></tr>
<tr><td ROWSPAN="2">--</td>
<td>decrement and then return value</td>
<td>x=3; --x</td>
<td><script><!--
x=3
document.write(--x)
// --></script>
</td></tr>
<tr><td>return value and then decrement</td>
<td>x=4; x--</td>
<td><script><!--
x=4
document.write(x--)
// --></script>
</td></tr>
<tr><td ROWSPAN="6">Bit Manipulation</td>
<td>&amp;</td>
<td>and</td>
<td>11 &amp; 7</td>
<td><script><!--
document.write(11&7)
// --></script>
</td></tr>
<tr><td>|</td>
<td>or</td>
<td>8 | 7</td>
<td><script><!--
document.write(8|7)
// --></script>
</td></tr>
<tr><td>^</td>
<td>exclusive or</td>
<td>1 ^ 7</td>
<td><script><!--
document.write(1^7)
// --></script>
</td></tr>
<tr><td>&lt;&lt;</td>
<td>left shift</td>
<td>8 &lt;&lt; 3</td>
<td><script><!--
document.write(8 << 3)
// --></script>
</td></tr>
<tr><td>&gt;&gt;</td>
<td>sign-propagating right shift</td>
<td>-3 &gt;&gt; 2</td>
<td><script><!--
document.write(-3 >> 2)
// --></script>
</td></tr>
<tr><td>&gt;&gt;&gt;</td>
<td>zero-fill right shift</td>
<td>-7 &gt;&gt;&gt; 3</td>
<td><script><!--
document.write(-7>>>3)
// --></script>
</td></tr>
<tr><td ROWSPAN="3">Logical</td>
<td>&amp;&amp;</td>
<td>logical and</td>
<td>true &amp;&amp; false</td>
<td><script><!--
document.write(true&&false)
// --></script>
</td></tr>
<tr><td>||</td>
<td>logical or</td>
<td>true || false</td>
<td><script><!--
document.write(true||false)
// --></script>
</td></tr>
<tr><td>!</td>
<td>not</td>
<td>!true</td>
<td><script><!--
document.write(!true)
// --></script>
</td></tr>
<tr><td ROWSPAN="6">Comparison</td>
<td>==</td>
<td>equal</td>
<td>3 == 7</td>
<td><script><!--
document.write(3==7)
// --></script>
</td></tr>
<tr><td>!=</td>
<td>not equal</td>
<td>3 != 7</td>
<td><script><!--
document.write(3!=7)
// --></script>
</td></tr>
<tr><td>&lt;</td>
<td>less than</td>
<td>3 &lt; 7</td>
<td><script><!--
document.write(3<7)
// --></script>
</td></tr>
<tr><td>&lt;=</td>
<td>less than or equal</td>
<td>3 &lt;= 7</td>
<td><script><!--
document.write(3<=7)
// --></script>
</td></tr>
<tr><td>&gt;</td>
<td>greater than</td>
<td>3 &gt; 7</td>
<td><script><!--
document.write(3>7)
// --></script>
</td></tr>
<tr><td>&gt;=</td>
<td>greater than or equal</td>
<td>3 &gt;= 7</td>
<td><script><!--
document.write(3>7)
// --></script>
</td></tr>
<tr><td>Conditional Expression</td>
<td>(condition) ? value1 : value2</td>
<td>if condition is true then value1 else value2</td>
<td>true ? 3 : 7</td>
<td><script><!--
document.write(true?3:7)
// --></script>
</td></tr>
</table>
</body>
</html>

           
         
    
  








Related examples in the same category

1.Using the Equal Operator
2.Examples of Increment and Decrement Operators
3.Working with the Increment Operator
4.Add two integer variables together
5.Subtract one integer variable from another integer variable
6.Multiply two integer variables together
7.Modular operation (remainder in division)
8.Prefix plus
9.Prefix subtraction
10.Postfix adding
11.Postfix subtraction
12.Postfix operator for integer
13.Prefix operator for integer
14.JavaScript compound plus assignment
15.JavaScript compound subtraction assignment
16.JavaScript compound multiply assignment
17.JavaScript compound divide assignment
18.Ternary operator
19.Tenary operator