If you freely compare a boolean value with a value of another type, the boolean value is forcibly entered into a number.
And when you compare the number and the string, the string is forcibly entered into the number.
Complete rules are explained in the Abstract Equality Comparison Algorithm
The process is as follows:
true == "true" ββ ββ Number(true) // 1 1 == "true" ββ€ ββ Number("true") // NaN 1 == NaN ββ€ ββ // Comparing with `NaN` always produces `false` false ββ
source share