Javascript Relational Operators Question 3

Introduction

What is the output of the following code?


console.log(3 == 3);            // 
console.log("3" == 3);          // 
console.log(false == 0);        // 
console.log(null == 0);         // 
console.log(null < 1);          //     


true
true
true
false, Number(null) gives 0
true  Number(null) gives 0

Note

Equality operators use coercion when comparing values if data types are different.

null & undefined always give weird results with coercion

avoid coercion completely




PreviousNext

Related