How do I read String comparison can be forced by: "" + a == "" + b from https://262.ecma-international.org/5.1/#sec-11.9.6?
Number() instead of unary +) to implement those conversions to make it more readable to a beginner?MDN has a table of operator precedence.
Addition (string and arithmetic) happens before equality. All else being equal, things are done left to right.
So given:
"" + a == "" + b
first "" + a is evaluated and is equivalent to String(a).
Then "" + b is evaluated and is equivalent to String(b).
The two results are then compared using ==.
It's used because it's less to write than String(a).
Whether Number(a) is more readable than +a is moot. There are things to learn about both. For conversion to number there is also parseInt, parseFloat and multiplication by 1, so all the following:
parseInt(a)
parseFloat(a)
+a
a * 1
might all give the same result (e.g. where a is an integer string like 10). But might not for other values (like '10.6'). Conversion to number is also complicated by NaN, so if either or both expressions resolve to NaN, then they don't equal each other ('cos NaN isn't == or === to any value, even itself).
Have fun. :-)