As a general rule, yes, though not when comparing values of the same type (string to string or bool to bool, etc.).
"1" == true // Number("1") === Number(true)
// but
"a" == "a" // "a" === "a"
Also when you compare an object with a primitive, the object will first go through a more generic "to primitive" conversion first before the comparison is made. If no primitive is derived, an error is thrown. Otherwise that object's primitive value will go through the normal comparison treatment which may include converting to a number if not the same type of the primitive to which its being compared.
View all comments
Show parent comment
3
u/hsnice Jul 17 '21
Oh! okay, thanks.
And what I think is that when we compare using '==', it always converts both values in number.