Javascript operators: Difference between revisions

From wikinotes
No edit summary
 
No edit summary
Line 1: Line 1:
<source lang="javascript">
= and/or =
<blockquote>
<syntaxhighlight lang="javascript">
&& ||      // condition AND/OR condition
&& ||      // condition AND/OR condition
</syntaxhighlight>
</blockquote><!-- and/or -->
= equality greater/less than =
<blockquote>
<syntaxhighlight lang="javascript">
== !=      // equals or not equals
=== !==    // same object instance?
=== !==    // same object instance?
< > <= >=  // greater-than less-than
< > <= >=  // greater-than less-than
</source>
</syntaxhighlight>
</blockquote><!-- equality greater/less than -->
 
= bitwise operators =
<blockquote>
<syntaxhighlight lang="javascript">
x | y      // bitwise or
x ^ y      // bitwise exclusive and
x & y      // bitwise and
x << n    // bitwise shift by n bits
x >> n    // bitwise shift by n bits
~x        // invert bits
</syntaxhighlight>
</blockquote><!-- bitwise operators -->

Revision as of 00:51, 31 July 2021

and/or

&& ||      // condition AND/OR condition

equality greater/less than

== !=      // equals or not equals
=== !==    // same object instance?
< > <= >=  // greater-than less-than

bitwise operators

x | y      // bitwise or
x ^ y      // bitwise exclusive and
x & y      // bitwise and
x << n     // bitwise shift by n bits
x >> n     // bitwise shift by n bits
~x         // invert bits