Equality


var x=1; 
var y='1';
if (x=y) {
   console.log("Equals");
} else {
   console.log("Not Equals");
}

Double Equals ==

performs automatic type conversion


Triple Equals ===

this avoids behind the scenes type conversion



The '===' operator checks for explicit type conversion

null === undefined            // false 
false === 0; // false
'' === 0; // false
123' === 123 // false

let num1 = 10;
let num2 = 10;
console.log( num1 == num2 ); // true
console.log( num1 === num2 ); // true

let num3 = new Number(10);
let num4 = new Number(10);
console.log( num3 == num4 ); // false
console.log( num3 === num4 ); // false



© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext