Conversions:

Just like for Numbers and "strings", (and also [arrays]booleans can also be converted.

We can convert a boolean into a Number. However, because a boolean has only two values (that is, true or false), thus a boolean can also have one of only two values, either 0 or 1.

A conversion of a true into a Number will return the number 1.

A conversion of a flase into a Number will return a 0.

Just like an electrical circuit, its either "on" or "off", or here, I/0.

  1. Boolean to Number:
  2. true.toString();

    false.toString();

  3. Boolean to "string":
  4. true.toString();

    false.toString();

It is also possible to perform Math operations on booleans:

  1. Unary Operations:
  2. +(or -)true, +(or -)false;

  3. Binary Operations:
  4. true + true etc;