MDC описывает оператор ==
следующим образом:
If the two operands are not of the same type, JavaScript converts the operands then applies strict comparison. If either operand is a number or a boolean, the operands are converted to numbers if possible; else if either operand is a string, the other operand is converted to a string if possible.
Имея это в виду, я бы оценил "true" == true
следующим образом:
isNaN(Number("true")) // true
)String(true) === "true" // true
)Я получил строки "true"
и "true"
, которые должны оцениваться как true
, но JavaScript показывает false.
Что я пропустил?