a=function(){
  return b!=="xx";
}
还有
a=function(){
  return b&&c;
}
分别是什么意思啊

解决方案 »

  1.   

    b!=='xx'为一个比较表达式,如果b==='xx',函数返回false,否则返回true
      

  2.   

    第二个函数是一个利用逻辑与短路求值特性的写法,如果b == true,返回b;否则返回c
      

  3.   


    反了。
    这样:
    a=function(){
      return b||c;
    }
    怎讲?
      

  4.   


    b和c均为真时,返回true,否则返回false
      

  5.   

    确实大意了,b == false,返回b,否则返回c 
      

  6.   


    a=function(){
       return b!=="xx";
     }equals:
    a=function(){
      if(b=='xx'){
        return false;
      }
      else{
        return true;
      }
    } a=function(){
       return b&&c;
     }equals:
    a=function(){
      if(b==true && c==true){
        return true;
      }
      else{
        return false;
      }
    }
      

  7.   


    a=function(){
      return b!=="xx";//!==为严格比较表达式,要求值和值类型都不相同才为true
    }
    //'1'==1为true    '1'!=1为false
    //'1'===1为false  '1'!==1为true
    a=function(){
      return b&&c;
    }
    //return a && b && c && d;返回第一个非真表达式。
    //真值表达式:所有对象、非空字符串、非0数字
    //非真表达式:空字符串、0、false、undefined、null
    //return 1 && null && false;返回null
    //return 1 && false && null;返回false//return a || b || c || d;返回第一个非假表达式
    //return null || 1 || 2;返回1
    //return null || 2 || 1;返回2