Type Conversion:

A litle note about converting from one data type to another in JavaScript:

What happens if you add a "string" to a boolean, Number or another "string"?

  1. "string" + boolean:
  2. JavaScript assumes that the boolean should be converted to a "string". Once done so, the two are concatenated.

  3. "string" + Number:
  4. JavaScript assumes that the Number should be converted to a "string". Once done so, the two are concatenated.

  5. Boolean * Number:
  6. JavaScript assumes that the boolean should be converted to a Number. Once done so, the two are mathematically operated upon.

  7. "string" * Number:
  8. JavaScript cannot be mathematically operated on by Numbers, thus we have NaN.