JavaScript Coding Question – 2

Output:

true
  • expr1 = (null <= 0): In JavaScript, null is converted to ‘0’ when compared with number which makes null <= 0 evaluate to true.
  • expr2 = ('' == false): The == operator performs type coercion. An empty string ('') is coerced to a number, which results in 0. Thus, '' == false evaluates to true because false is also coerced to 0.
  • result = (expr1 === expr2): Since both expr1 and expr2 are true, the comparison true === true evaluates to true.

Leave a comment