JavaScript Learning Notes: Comparisions


                    console.log("a" > 1);
                    console.log("02" > 1);
                    console.log("02" > "1");
                

Console Output:
false
true
false



                    console.log(null > 0);
                    console.log(null == 0);
                    console.log(null >= 0);
                

Console Output:
false
false
true



                    console.log(undefined == 0);
                    console.log(undefined > 0);
                    console.log(undefined < 0);
                

Console Output:
false
false
false



                    console.log("2" == 2);
                    console.log("2" === 2);
                

Console Output:
true
false

Difference Between == and === in JavaScript

In JavaScript, == and === are comparison operators, but they work differently:

Consider the following examples:


                    console.log("2" == 2);  // Output: true
                    console.log("2" === 2); // Output: false
                

Explanation: