Why is it true=null and false==null both give false?



  • What's wrong with my Firefox and Chrome, in both browsers, is a simple test that gives contradictory reason and specifications the result:

    [ true == null, false == null]
    /*
    false,false
    */
    

    There's no change in the result from redistribution. Same picture with undefined:

    [ undefined == true, undefined == false, undefined == null]
    /*
    false,false,true
    */
    

    If a type of facility is established Booleanit's getting like:

    [ new Boolean(null) == true, new Boolean(null) == false]
    /*
    false,true
    */
    


  • Because... https://es5.github.io/#x11.9.3 if Type(x) or Type(y) are Boolean when compared x == yThen Boolean number by ToNumberwhich converts true Total 1 and false Total +0

    If it's simple, there's no match in JS. bool and nullnull In JS, it's a type. So by comparing it to something else, you'll always get it. false


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2