Operators and Expressions : Operator : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » Operator »

 

Operators and Expressions



<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</td>
<td><script><!--
document.write(3+3)
// --></script>
</td></tr>
<tr><td ROWSPAN="2">-</td>
<td>subtraction</td>
<td>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</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>7</td>
<td><script><!--
document.write(8|7)
// --></script>
</td></tr>
<tr><td>^</td>
<td>exclusive or</td>
<td>7</td>
<td><script><!--
document.write(1^7)
// --></script>
</td></tr>
<tr><td>&lt;&lt;</td>
<td>left shift</td>
<td>&lt;&lt; 3</td>
<td><script><!--
document.write(<< 3)
// --></script>
</td></tr>
<tr><td>&gt;&gt;</td>
<td>sign-propagating right shift</td>
<td>-&gt;&gt; 2</td>
<td><script><!--
document.write(->> 2)
// --></script>
</td></tr>
<tr><td>&gt;&gt;&gt;</td>
<td>zero-fill right shift</td>
<td>-&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>== 7</td>
<td><script><!--
document.write(3==7)
// --></script>
</td></tr>
<tr><td>!=</td>
<td>not equal</td>
<td>!= 7</td>
<td><script><!--
document.write(3!=7)
// --></script>
</td></tr>
<tr><td>&lt;</td>
<td>less than</td>
<td>&lt; 7</td>
<td><script><!--
document.write(3<7)
// --></script>
</td></tr>
<tr><td>&lt;=</td>
<td>less than or equal</td>
<td>&lt;= 7</td>
<td><script><!--
document.write(3<=7)
// --></script>
</td></tr>
<tr><td>&gt;</td>
<td>greater than</td>
<td>&gt; 7</td>
<td><script><!--
document.write(3>7)
// --></script>
</td></tr>
<tr><td>&gt;=</td>
<td>greater than or equal</td>
<td>&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 7</td>
<td><script><!--
document.write(true?3:7)
// --></script>
</td></tr>
</table>
</body>
</html>

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» Operator