Most of the time, operators and functions automatically convert the values given to them to the right type.
we can call the String(value) function to convert a value to string.
we can use the Number(value) function to explicitly convert a value to a number.
If the string is not a valid number, the result of such a conversion is NaN.
Numeric conversion rules...
undefined → NaN
null → 0
true and false → 1 and 0
string → Whitespaces from the start and end are removed. If the remaining string is empty, the result is 0. Otherwise, the number is 'read' from the string. An error gives NaN.
The conversion rule:
*in Javascript, a non-empty string is always true.
alert(Boolean(' ')); // true
false ← 0, null, undefined, NaN, ""
true ← any other value, "0"