JS Daily 38 - Adding Two Boolean Values

Last updated on 28 Dec, 2020

What is the output of following code?

console.log(true + true);

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.

--- ○ ---
Joby Joseph
Web Architect