The difference between double and triple equals equality operators in JS is the typecast. While strict equality immediately returns 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.

In JavaScript there are 2 equality operators:

  • 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 return false, while the loose equality operator still returns true.

const x = 10;
const y = '10';

console.log(x == y);  // true
console.log(x === y); // false

Strict equality in JS

You can check strict equality in JavaScript using the operator ===.

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