### In JavaScript, what is the result of the following: (true + false) > (2 + true);

- false
- TypeError
- NaN
- true

#### EXPLANATION

The above line of JavaScript returns false. Why? The reason is called type coercion. You're using two boolean values in an arithmetic operation, which is not possible unless the interpreter converts them into numbers first. So consider the following:If you evaluate the statements, you find that true equals 1 and false equals 0. So your expression is equivalent to:

(1 + 0) > 2 + 1

which reduces to:

1 > 3

which is false!

## 0 comments:

## Post a Comment