Explain the difference between `==` and `===`

Beginner

Answer

  • == (loose equality): Performs type coercion before comparison
  • === (strict equality): Compares both value and type without coercion
5 == "5";    // true (coercion)
5 === "5";   // false (different types)
null == undefined;  // true
null === undefined; // false