if 判断中出现逗号

Posted 乏mily

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了if 判断中出现逗号相关的知识,希望对你有一定的参考价值。

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> New Document </title>
  <script type="text/javascript">
  window.onload=function(){
       if(1>2,2>3)//false,false
       {
           alert(1>2,2>3 - true );
       }
       else
       {
           alert(1>2,2>3 - false );
       }
       
       if(1>2,2<3)//false,true
       {
           alert("1>2,2<3 - true");
       }
       else{
           alert(1>2,2<3 - false );
       }
       if(1<2,2>3)//true,false
       {
           alert(1<2,2>3 - true );
       }
       else
       {
           alert(1<2,2>3 - false );
       }
       
       if(1<2,2<3)//true,true
       {
           alert("1<2,2<3 - true");
       }
       else{
           alert(1<2,2<3 - false );
       }

       if(1>2 || 2>3 , 5>2)
       {
           alert(1>2||2>3, 5>2 - true );
       }
       else
       {
           alert(1>2||2>3, 5>2 - false );
       }

       if(1>2 || 2>3 , 5<2)
       {
           alert(1>2||2>3, 5<2 - true );
       }
       else
       {
           alert(1>2||2>3, 5<2 - false );
       }
  }
  </script>
 </head>
 <body>  
 </body>
</html>

  运行上面的代码会发现,if 判断条件 会以 逗号分隔后的两个表达式中的最后一个表达式的结果 为准

以上是关于if 判断中出现逗号的主要内容,如果未能解决你的问题,请参考以下文章

java用if语句要怎么判断一个字符串里是不是有逗号?

PHP常用代码片段

javascript常用代码片段

在 Oracle PLSQL 函数的输出过程中出现逗号问题

js 每三位数添加逗号

判断一个数值是否在一个逗号分隔的字符串中