What is the output of following code?
console.log(true + true);
----o----
The output is 2
.
When both the operands for +
is of type Boolean, both the operands are converted to numbers. true
is converted to 1
and false
is converted to 0
. That is why the result printed as 2
.