const expr1 = (null <= 0);
const expr2 = ('' == false);
const result = (expr1 === expr2);
console.log(result)
Output:
true
expr1 = (null <= 0): In JavaScript,nullis converted to ‘0’ when compared with number which makesnull <= 0evaluate totrue.expr2 = ('' == false): The==operator performs type coercion. An empty string ('') is coerced to a number, which results in0. Thus,'' == falseevaluates totruebecausefalseis also coerced to0.result = (expr1 === expr2): Since bothexpr1andexpr2aretrue, the comparisontrue === trueevaluates totrue.
Discover more from Learners Store
Subscribe to get the latest posts sent to your email.