The rules are given in the Abstract Equality Comparison algorithm.
Does right side of operator is forced to convert to type on left?
number == string -> number == number
Step 4: If Type(x)
is Number and Type(y)
is String, return the result of the comparison x == ToNumber(y)
.
So yes.
Are both sides converted to same underlying type, like number?
boolean == string -> number == number
Step 6: If Type(x)
is Boolean, return the result of the comparison ToNumber(x) == y
.
which gives different types (number and string), so it goes to Step 4: number == ToNumber(y)
.
So yes again.
Are there different rules of every operator *-/+||&&%??
Other operators may do coercion of the result of evaluating the expression so I guess "Yes". Read the relevant parts of ECMA-262#expressions.