The difference between double and triple equals equality operators in JS is the typecast. While strict equality
false if the operand types are different, loose equality operator first tries to convert
both values to a common type. Let’s get into details.
- loose equality operator
- strict equality operator
There’s no difference between these operators when the operands are of the same type.
const x = 10; const y = 10; console.log(x == y); // true console.log(x === y); // true
If you change the value of
y to the string
10 instead of the number
10, strict equality operator will
false, while the loose equality operator still returns
const x = 10; const y = '10'; console.log(x == y); // true console.log(x === y); // false
Strict equality in JS
const a = 2; const b = 2; const c = 3; console.log(a === b); // true console.log(a === c); // false
This operator does strict comparison and considers the elements