日度归档:2020年9月27日

javascript中位运算的示例说明


摘要:
下文通过示例的方式javascript中运算的相关说明,如下所示;

位运算的功能:
js中位运算符用于数值转为二进制后进行相关运算,
左移指定位数,右移指定位数的操作,
下例将展示位运算的相关说明,如下所示:
例:

  <meta charset='utf-8' />
<p>
 maomao365.com<br />
 js位运算示例说明 
</p>
<hr />      
      <script>
         <!--
            var a = 8; //二进制 1000
            var b = 9; //二进制 1001
            var newLine = "<br />";
         
            document.write("(a & b) => ");
            result = (a & b);
            document.write(result);
            document.write(newLine);
         
            document.write("(a | b) => ");
            result = (a | b);
            document.write(result);
            document.write(newLine);
         
            document.write("(a ^ b) => ");
            result = (a ^ b);
            document.write(result);
            document.write(newLine);
         
            document.write("(~b) => ");
            result = (~b);
            document.write(result);
            document.write(newLine);
         
            document.write("(a << b) => ");
            result = (a << b);
            document.write(result);
            document.write(newLine);
         
            document.write("(a >> b) => ");
            result = (a >> b);
            document.write(result);
            document.write(newLine);
         //-->
      </script> 
javascript位运算示例说明

javascript位运算示例说明

javascript中逻辑运算符示例说明


摘要:
下文通过示例的方式javascript中逻辑运算符的相关说明,如下所示;

逻辑运算符的功能:
js中逻辑运算符用于两个值之间进行与非计算,
计算后,返回一个布尔值,
下文通过示例的方式讲述与非计算
例:

<meta charset='utf-8' />
<p>
 maomao365.com<br />
 js逻辑运算符示例说明 
</p>
<hr />      
      <script>
         <!--
            var a = true;
            var b = false;
            var newLine = "<br />";
      
            document.write("(a && b) => ");
            result = (a && b);
            document.write(result);
            document.write(newLine);
         
            document.write("(a || b) => ");
            result = (a || b);
            document.write(result);
            document.write(newLine);
         
            document.write("!(a && b) => ");
            result = (!(a && b));
            document.write(result);
            document.write(newLine);
         //-->
      </script>  
javascript逻辑运算符示例说明

javascript逻辑运算符示例说明

javascript中比较运算符示例说明


摘要:
下文通过示例的方式javascript中比较运算符的相关说明,如下所示;

比较运算符的功能:
js中比较运算符用于比较两个数的大小,
比较后,返回一个布尔值,例:

 <meta charset='utf-8' />
<p>
 maomao365.com<br />
 js比较运算符示例说明 
</p>
<hr />  
<script> 
            var a = 88;
            var b = 99;
            var newLine = "<br />";
      
            document.write("(a == b) => ");
            result = (a == b);
            document.write(result);
            document.write(newLine);
         
            document.write("(a < b) => ");
            result = (a < b);
            document.write(result);
            document.write(newLine);
         
            document.write("(a > b) => ");
            result = (a > b);
            document.write(result);
            document.write(newLine);
         
            document.write("(a != b) => ");
            result = (a != b);
            document.write(result);
            document.write(newLine);
         
            document.write("(a >= b) => ");
            result = (a >= b);
            document.write(result);
            document.write(newLine);
         
            document.write("(a <= b) => ");
            result = (a <= b);
            document.write(result);
            document.write(newLine);
        </script>
JavaScript中比较运算符的示例说明

JavaScript中比较运算符的示例说明