Javascript operators: Difference between revisions

From wikinotes
No edit summary
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<source lang="javascript">
= and/or =
<blockquote>
<syntaxhighlight lang="javascript">
&& ||      // condition AND/OR condition
&& ||      // condition AND/OR condition
=== !==    // same object instance?
</syntaxhighlight>
</blockquote><!-- and/or -->
 
= equality greater/less than =
<blockquote>
<syntaxhighlight lang="javascript">
== !=      // equality        ( '1' == 1 )
=== !==    // strict equality ( '1' !=== 1 )
< > <= >=  // greater-than less-than
< > <= >=  // greater-than less-than
</source>
</syntaxhighlight>
 
* equality:        https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality
* strict-equality: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality
</blockquote><!-- equality greater/less than -->
 
= bitwise operators =
<blockquote>
<syntaxhighlight lang="javascript">
x | y      // bitwise or              (set binary bit)
x ^ y      // bitwise exclusive and    (unset binary bit)
x & y      // bitwise and              (intersection of binary bits)
x << n    // bitwise shift by n bits
x >> n    // bitwise shift by n bits
~x        // invert bits
</syntaxhighlight>
</blockquote><!-- bitwise operators -->

Latest revision as of 21:48, 27 August 2021

and/or

&& ||      // condition AND/OR condition

equality greater/less than

== !=      // equality        ( '1' == 1 )
=== !==    // strict equality ( '1' !=== 1 )
< > <= >=  // greater-than less-than

bitwise operators

x | y      // bitwise or               (set binary bit)
x ^ y      // bitwise exclusive and    (unset binary bit)
x & y      // bitwise and              (intersection of binary bits)
x << n     // bitwise shift by n bits
x >> n     // bitwise shift by n bits
~x         // invert bits