Почему «true» == true показывает false в JavaScript?
MDC описывает==
operator as follows:
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
)
Is either operand a string? Yes
Can we convert the other operand to a string? Yes (String(true) === "true" // true
)
Я закончил со строками"true"
а также"true"
, который должен оценить, чтобыtrue
, но JavaScript показывает false.
Что я пропустил?