The Boolean value of false is, as expected, false.
| let x = false; |
However, booleans can also be created as objects using the new keyword.
| let y = new Boolean(false); |
| let x = false; let y = new Boolean(false); // typeof x returns boolean // typeof y returns object |
|
Avoid creating Boolean objects. Using the Boolean objects may lead to unexpected results. |
When using the == operator, x and y are considered equal.
| let x = false; let y = new Boolean(false); |
When using the === operator, x and y are not considered equal.
| Pay attention to the difference between (x == y) and (x === y). |
Is (x == y) true or false?
| let x = new Boolean(false); let y = new Boolean(false); |
Is (x === y) true or false?
| let x = new Boolean(false); let y = new Boolean(false); |