This question has already been answered:

function isTrue(){ var a = ('false' == false); console.log(a); }; isTrue(); 

Reported as a duplicate at Grundy. javascript 5 May '17 at 10:10

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • one
    And why would true ? - D-side
  • 2
    Because 'false' != false . On the one hand a line, and on the other a boolean expression. - Pyramidhead
  • one
    Because when comparing String and Boolean both operands are cast to Number , after which the comparison itself occurs. 'false' is NaN to NaN , false to 0 . And NaN not equal to 0 . - Regent

1 answer 1

Check:

 typeof('false'); // === 'string' typeof(false); // === boolean 
  • one
    [] == false , with typeof([]) // object and typeof(false); // === boolean typeof(false); // === boolean so what does your answer show? - Grundy
  • one
    And so what types are different? console.log("0" == false); Quite true , for example. - Regent
  • In the question == , not === . Why would the types be compared here? - Qwertiy ♦